8000 Add support for texture arrays · BabylonJS/BabylonNative@88869e4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 88869e4

Browse files
committed
Add support for texture arrays
1 parent be6b60c commit 88869e4

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

Plugins/ExternalTexture/Source/ExternalTexture_Base.h

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace Babylon::Plugins
1616
uint16_t Height() const { return m_info.Height; }
1717
bgfx::TextureFormat::Enum Format() const { return m_info.Format; }
1818
bool HasMips() const { return m_info.MipLevels != 1; }
19+
uint16_t NumLayers() const { return m_info.NumLayers; }
1920
uint64_t Flags() const { return m_info.Flags; }
2021

2122
void AddHandle(bgfx::TextureHandle handle)
@@ -87,6 +88,7 @@ namespace Babylon::Plugins
8788
uint16_t Width{};
8889
uint16_t Height{};
8990
uint16_t MipLevels{};
91+
uint16_t NumLayers{};
9092
bgfx::TextureFormat::Enum Format{bgfx::TextureFormat::Unknown};
9193
uint64_t Flags{};
9294
};

Plugins/ExternalTexture/Source/ExternalTexture_D3D11.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ namespace Babylon::Plugins
185185
info.Width = static_cast<uint16_t>(desc.Width);
186186
info.Height = static_cast<uint16_t>(desc.Height);
187187
info.MipLevels = static_cast<uint16_t>(desc.MipLevels);
188+
info.NumLayers = static_cast<uint16_t>(desc.ArraySize);
188189

189190
if ((desc.BindFlags & D3D11_BIND_RENDER_TARGET) != 0)
190191
{

Plugins/ExternalTexture/Source/ExternalTexture_D3D12.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ namespace Babylon::Plugins
179179
info.Width = static_cast<uint16_t>(desc.Width);
180180
info.Height = static_cast<uint16_t>(desc.Height);
181181
info.MipLevels = static_cast<uint16_t>(desc.MipLevels);
182+
info.NumLayers = static_cast<uint16_t>(desc.ArraySize);
182183

183184
if ((desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET) != 0)
184185
{

Plugins/ExternalTexture/Source/ExternalTexture_Metal.mm

+1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ static void GetInfo(Graphics::TextureT ptr, std::optional<Graphics::TextureForma
163163
info.Width = static_cast<uint16_t>(ptr.width);
164164
info.Height = static_cast<uint16_t>(ptr.height);
165165
info.MipLevels = static_cast<uint16_t>(ptr.mipmapLevelCount);
166+
info.NumLayers = static_cast<uint16_t>(ptr.arrayLength);
166167

167168
if ((ptr.usage & MTLTextureUsageRenderTarget) != 0)
168169
{

Plugins/ExternalTexture/Source/ExternalTexture_Shared.h

+2-7
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ namespace Babylon::Plugins
1919
Info info;
2020
GetInfo(ptr, overrideFormat, info);
2121

22-
//if (info.Width != m_info.Width || info.Height != m_info.Height || info.MipLevels != m_info.MipLevels)
23-
//{
24-
// return false;
25-
//}
26-
2722
DEBUG_TRACE("ExternalTexture [0x%p] Update %d x %d %d mips", this, int(info.Width), int(info.Height), int(info.MipLevels));
2823

2924
m_info = info;
@@ -76,8 +71,8 @@ namespace Babylon::Plugins
7671
[&context, &runtime, deferred = std::move(deferred), impl = m_impl]() {
7772
// REVIEW: The bgfx texture handle probably needs to be an RAII object to make sure it gets clean up during the asynchrony.
7873
// For example, if any of the schedulers/dispatches below don't fire, then the texture handle will leak.
79-
bgfx::TextureHandle handle = bgfx::createTexture2D(impl->Width(), impl->Height(), impl->HasMips(), 1, impl->Format(), impl->Flags());
80-
DEBUG_TRACE("ExternalTexture [0x%p] create %d x %d %d mips. Format : %d Flags : %d. (bgfx handle id %d)", impl.get(), int(impl->Width()), int(impl->Height()), int(impl->HasMips()), int(impl->Format()), int(impl->Flags()), int(handle.idx));
74+
bgfx::TextureHandle handle = bgfx::createTexture2D(impl->Width(), impl->Height(), impl->HasMips(), impl->NumLayers(), impl->Format(), impl->Flags());
75+
DEBUG_TRACE("ExternalTexture [0x%p] create %d x %d %d mips %d layers. Format : %d Flags : %d. (bgfx handle id %d)", impl.get(), int(impl->Width()), int(impl->Height()), int(impl->HasMips()), int(impl->NumLayers()), int(impl->Format()), int(impl->Flags()), int(handle.idx));
8176
if (!bgfx::isValid(handle))
8277
{
8378
DEBUG_TRACE("ExternalTexture [0x%p] is not valid", impl.get());
391B

0 commit comments

Comments
 (0)
0