summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/src
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/src')
-rw-r--r--3rdparty/bgfx/src/bgfx.cpp32
-rw-r--r--3rdparty/bgfx/src/bgfx_p.h32
-rw-r--r--3rdparty/bgfx/src/image.cpp52
-rw-r--r--3rdparty/bgfx/src/renderer_d3d11.cpp43
-rw-r--r--3rdparty/bgfx/src/renderer_d3d11.h4
-rw-r--r--3rdparty/bgfx/src/renderer_d3d12.cpp10
-rw-r--r--3rdparty/bgfx/src/renderer_d3d12.h4
-rw-r--r--3rdparty/bgfx/src/renderer_d3d9.cpp10
-rw-r--r--3rdparty/bgfx/src/renderer_d3d9.h2
-rw-r--r--3rdparty/bgfx/src/renderer_gl.cpp30
-rw-r--r--3rdparty/bgfx/src/renderer_gl.h5
-rw-r--r--3rdparty/bgfx/src/renderer_mtl.h2
-rw-r--r--3rdparty/bgfx/src/renderer_mtl.mm8
-rw-r--r--3rdparty/bgfx/src/renderer_null.cpp2
14 files changed, 133 insertions, 103 deletions
diff --git a/3rdparty/bgfx/src/bgfx.cpp b/3rdparty/bgfx/src/bgfx.cpp
index aae0311ebd5..e16d4f71c3f 100644
--- a/3rdparty/bgfx/src/bgfx.cpp
+++ b/3rdparty/bgfx/src/bgfx.cpp
@@ -2259,13 +2259,10 @@ again:
uint8_t num;
_cmdbuf.read(num);
- TextureHandle textureHandles[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
- for (uint32_t ii = 0; ii < num; ++ii)
- {
- _cmdbuf.read(textureHandles[ii]);
- }
+ Attachment attachment[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
+ _cmdbuf.read(attachment, sizeof(Attachment) * num);
- m_renderCtx->createFrameBuffer(handle, num, textureHandles);
+ m_renderCtx->createFrameBuffer(handle, num, attachment);
}
}
break;
@@ -3112,14 +3109,27 @@ again:
FrameBufferHandle createFrameBuffer(uint8_t _num, const TextureHandle* _handles, bool _destroyTextures)
{
+ Attachment attachment[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
+ for (uint8_t ii = 0; ii < _num; ++ii)
+ {
+ Attachment& at = attachment[ii];
+ at.handle = _handles[ii];
+ at.mip = 0;
+ at.layer = 0;
+ }
+ return createFrameBuffer(_num, attachment, _destroyTextures);
+ }
+
+ FrameBufferHandle createFrameBuffer(uint8_t _num, const Attachment* _attachment, bool _destroyTextures)
+ {
BGFX_CHECK_MAIN_THREAD();
BX_CHECK(_num != 0, "Number of frame buffer attachments can't be 0.");
BX_CHECK(_num <= BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS, "Number of frame buffer attachments is larger than allowed %d (max: %d)."
, _num
, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS
);
- BX_CHECK(NULL != _handles, "_handles can't be NULL");
- return s_ctx->createFrameBuffer(_num, _handles, _destroyTextures);
+ BX_CHECK(NULL != _attachment, "_attachment can't be NULL");
+ return s_ctx->createFrameBuffer(_num, _attachment, _destroyTextures);
}
FrameBufferHandle createFrameBuffer(void* _nwh, uint16_t _width, uint16_t _height, TextureFormat::Enum _depthFormat)
@@ -4114,10 +4124,10 @@ BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_scaled(bgfx_backb
return handle.c;
}
-BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_handles(uint8_t _num, const bgfx_texture_handle_t* _handles, bool _destroyTextures)
+BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_attachment(uint8_t _num, const bgfx_attachment_t* _attachment, bool _destroyTextures)
{
union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle;
- handle.cpp = bgfx::createFrameBuffer(_num, (const bgfx::TextureHandle*)_handles, _destroyTextures);
+ handle.cpp = bgfx::createFrameBuffer(_num, (const bgfx::Attachment*)_attachment, _destroyTextures);
return handle.c;
}
@@ -4560,7 +4570,7 @@ BGFX_C_API bgfx_interface_vtbl_t* bgfx_get_interface(uint32_t _version)
BGFX_IMPORT_FUNC(destroy_texture) \
BGFX_IMPORT_FUNC(create_frame_buffer) \
BGFX_IMPORT_FUNC(create_frame_buffer_scaled) \
- BGFX_IMPORT_FUNC(create_frame_buffer_from_handles) \
+ BGFX_IMPORT_FUNC(create_frame_buffer_from_attachment) \
BGFX_IMPORT_FUNC(create_frame_buffer_from_nwh) \
BGFX_IMPORT_FUNC(destroy_frame_buffer) \
BGFX_IMPORT_FUNC(create_uniform) \
diff --git a/3rdparty/bgfx/src/bgfx_p.h b/3rdparty/bgfx/src/bgfx_p.h
index 594310d284f..1434b5ca41f 100644
--- a/3rdparty/bgfx/src/bgfx_p.h
+++ b/3rdparty/bgfx/src/bgfx_p.h
@@ -573,8 +573,14 @@ namespace bgfx
const char* getPredefinedUniformName(PredefinedUniform::Enum _enum);
PredefinedUniform::Enum nameToPredefinedUniformEnum(const char* _name);
- struct CommandBuffer
+ class CommandBuffer
{
+ BX_CLASS(CommandBuffer
+ , NO_COPY
+ , NO_ASSIGNMENT
+ );
+
+ public:
CommandBuffer()
: m_pos(0)
, m_size(BGFX_CONFIG_MAX_COMMAND_BUFFER_SIZE)
@@ -690,10 +696,6 @@ namespace bgfx
uint32_t m_pos;
uint32_t m_size;
uint8_t m_buffer[BGFX_CONFIG_MAX_COMMAND_BUFFER_SIZE];
-
- private:
- CommandBuffer(const CommandBuffer&);
- void operator=(const CommandBuffer&);
};
#define SORT_KEY_NUM_BITS_TRANS 2
@@ -2050,7 +2052,7 @@ namespace bgfx
virtual void overrideInternal(TextureHandle _handle, uintptr_t _ptr) = 0;
virtual uintptr_t getInternal(TextureHandle _handle) = 0;
virtual void destroyTexture(TextureHandle _handle) = 0;
- virtual void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const TextureHandle* _textureHandles) = 0;
+ virtual void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const Attachment* _attachment) = 0;
virtual void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat) = 0;
virtual void destroyFrameBuffer(FrameBufferHandle _handle) = 0;
virtual void createUniform(UniformHandle _handle, UniformType::Enum _type, uint16_t _num, const char* _name) = 0;
@@ -3182,14 +3184,14 @@ namespace bgfx
cmdbuf.write(_mem);
}
- bool checkFrameBuffer(uint8_t _num, const TextureHandle* _handles) const
+ bool checkFrameBuffer(uint8_t _num, const Attachment* _attachment) const
{
uint8_t color = 0;
uint8_t depth = 0;
for (uint32_t ii = 0; ii < _num; ++ii)
{
- TextureHandle texHandle = _handles[ii];
+ TextureHandle texHandle = _attachment[ii].handle;
if (isDepth(TextureFormat::Enum(m_textureRef[texHandle.idx].m_format)))
{
++depth;
@@ -3205,9 +3207,9 @@ namespace bgfx
;
}
- BGFX_API_FUNC(FrameBufferHandle createFrameBuffer(uint8_t _num, const TextureHandle* _handles, bool _destroyTextures) )
+ BGFX_API_FUNC(FrameBufferHandle createFrameBuffer(uint8_t _num, const Attachment* _attachment, bool _destroyTextures) )
{
- BX_CHECK(checkFrameBuffer(_num, _handles)
+ BX_CHECK(checkFrameBuffer(_num, _attachment)
, "Too many frame buffer attachments (num attachments: %d, max color attachments %d)!"
, _num
, g_caps.maxFBAttachments
@@ -3226,26 +3228,26 @@ namespace bgfx
FrameBufferRef& ref = m_frameBufferRef[handle.idx];
ref.m_window = false;
memset(ref.un.m_th, 0xff, sizeof(ref.un.m_th) );
- BackbufferRatio::Enum bbRatio = BackbufferRatio::Enum(m_textureRef[_handles[0].idx].m_bbRatio);
+ BackbufferRatio::Enum bbRatio = BackbufferRatio::Enum(m_textureRef[_attachment[0].handle.idx].m_bbRatio);
for (uint32_t ii = 0; ii < _num; ++ii)
{
- TextureHandle texHandle = _handles[ii];
+ TextureHandle texHandle = _attachment[ii].handle;
BGFX_CHECK_HANDLE("createFrameBuffer texture handle", m_textureHandle, texHandle);
BX_CHECK(bbRatio == m_textureRef[texHandle.idx].m_bbRatio, "Mismatch in texture back-buffer ratio.");
BX_UNUSED(bbRatio);
- cmdbuf.write(texHandle);
-
ref.un.m_th[ii] = texHandle;
textureIncRef(texHandle);
}
+
+ cmdbuf.write(_attachment, sizeof(Attachment) * _num);
}
if (_destroyTextures)
{
for (uint32_t ii = 0; ii < _num; ++ii)
{
- textureTakeOwnership(_handles[ii]);
+ textureTakeOwnership(_attachment[ii].handle);
}
}
diff --git a/3rdparty/bgfx/src/image.cpp b/3rdparty/bgfx/src/image.cpp
index 6f8f79775fa..34dcae9e54c 100644
--- a/3rdparty/bgfx/src/image.cpp
+++ b/3rdparty/bgfx/src/image.cpp
@@ -4,8 +4,6 @@
*/
#include "bgfx_p.h"
-#include <math.h> // powf, sqrtf
-
#include "image.h"
namespace bgfx
@@ -345,30 +343,30 @@ namespace bgfx
const uint8_t* rgba = src;
for (uint32_t xx = 0; xx < dstwidth; ++xx, rgba += 8, dst += 4)
{
- float rr = powf(rgba[ 0], 2.2f);
- float gg = powf(rgba[ 1], 2.2f);
- float bb = powf(rgba[ 2], 2.2f);
- float aa = rgba[ 3];
- rr += powf(rgba[ 4], 2.2f);
- gg += powf(rgba[ 5], 2.2f);
- bb += powf(rgba[ 6], 2.2f);
- aa += rgba[ 7];
- rr += powf(rgba[_pitch+0], 2.2f);
- gg += powf(rgba[_pitch+1], 2.2f);
- bb += powf(rgba[_pitch+2], 2.2f);
- aa += rgba[_pitch+3];
- rr += powf(rgba[_pitch+4], 2.2f);
- gg += powf(rgba[_pitch+5], 2.2f);
- bb += powf(rgba[_pitch+6], 2.2f);
- aa += rgba[_pitch+7];
+ float rr = bx::fpow(rgba[ 0], 2.2f);
+ float gg = bx::fpow(rgba[ 1], 2.2f);
+ float bb = bx::fpow(rgba[ 2], 2.2f);
+ float aa = rgba[ 3];
+ rr += bx::fpow(rgba[ 4], 2.2f);
+ gg += bx::fpow(rgba[ 5], 2.2f);
+ bb += bx::fpow(rgba[ 6], 2.2f);
+ aa += rgba[ 7];
+ rr += bx::fpow(rgba[_pitch+0], 2.2f);
+ gg += bx::fpow(rgba[_pitch+1], 2.2f);
+ bb += bx::fpow(rgba[_pitch+2], 2.2f);
+ aa += rgba[_pitch+3];
+ rr += bx::fpow(rgba[_pitch+4], 2.2f);
+ gg += bx::fpow(rgba[_pitch+5], 2.2f);
+ bb += bx::fpow(rgba[_pitch+6], 2.2f);
+ aa += rgba[_pitch+7];
rr *= 0.25f;
gg *= 0.25f;
bb *= 0.25f;
aa *= 0.25f;
- rr = powf(rr, 1.0f/2.2f);
- gg = powf(gg, 1.0f/2.2f);
- bb = powf(bb, 1.0f/2.2f);
+ rr = bx::fpow(rr, 1.0f/2.2f);
+ gg = bx::fpow(gg, 1.0f/2.2f);
+ bb = bx::fpow(bb, 1.0f/2.2f);
dst[0] = (uint8_t)rr;
dst[1] = (uint8_t)gg;
dst[2] = (uint8_t)bb;
@@ -3176,7 +3174,7 @@ namespace bgfx
{
float nx = temp[ii*4+2]*2.0f/255.0f - 1.0f;
float ny = temp[ii*4+1]*2.0f/255.0f - 1.0f;
- float nz = sqrtf(1.0f - nx*nx - ny*ny);
+ float nz = bx::fsqrt(1.0f - nx*nx - ny*ny);
temp[ii*4+0] = uint8_t( (nz + 1.0f)*255.0f/2.0f);
temp[ii*4+3] = 0;
}
@@ -3323,10 +3321,10 @@ namespace bgfx
const uint8_t* rgba = src;
for (uint32_t xx = 0; xx < dstwidth; ++xx, rgba += 4, dst += 4)
{
- dst[0] = powf(rgba[ 0], 2.2f);
- dst[1] = powf(rgba[ 1], 2.2f);
- dst[2] = powf(rgba[ 2], 2.2f);
- dst[3] = rgba[ 3];
+ dst[0] = bx::fpow(rgba[0], 2.2f);
+ dst[1] = bx::fpow(rgba[1], 2.2f);
+ dst[2] = bx::fpow(rgba[2], 2.2f);
+ dst[3] = rgba[3];
}
}
}
@@ -3395,7 +3393,7 @@ namespace bgfx
{
float nx = temp[ii*4+2]*2.0f/255.0f - 1.0f;
float ny = temp[ii*4+1]*2.0f/255.0f - 1.0f;
- float nz = sqrtf(1.0f - nx*nx - ny*ny);
+ float nz = bx::fsqrt(1.0f - nx*nx - ny*ny);
const uint32_t offset = (yy*4 + ii/4)*_width*16 + (xx*4 + ii%4)*16;
float* block = (float*)&dst[offset];
diff --git a/3rdparty/bgfx/src/renderer_d3d11.cpp b/3rdparty/bgfx/src/renderer_d3d11.cpp
index 5bacc5561d4..4446d6b0324 100644
--- a/3rdparty/bgfx/src/renderer_d3d11.cpp
+++ b/3rdparty/bgfx/src/renderer_d3d11.cpp
@@ -1778,9 +1778,9 @@ BX_PRAGMA_DIAGNOSTIC_POP();
m_textures[_handle.idx].destroy();
}
- void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const TextureHandle* _textureHandles) BX_OVERRIDE
+ void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const Attachment* _attachment) BX_OVERRIDE
{
- m_frameBuffers[_handle.idx].create(_num, _textureHandles);
+ m_frameBuffers[_handle.idx].create(_num, _attachment);
}
void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat) BX_OVERRIDE
@@ -4252,7 +4252,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
return handle;
}
- void FrameBufferD3D11::create(uint8_t _num, const TextureHandle* _handles)
+ void FrameBufferD3D11::create(uint8_t _num, const Attachment* _attachment)
{
for (uint32_t ii = 0; ii < BX_COUNTOF(m_rtv); ++ii)
{
@@ -4262,7 +4262,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
m_swapChain = NULL;
m_numTh = _num;
- memcpy(m_th, _handles, _num*sizeof(TextureHandle) );
+ memcpy(m_attachment, _attachment, _num*sizeof(Attachment) );
postReset();
}
@@ -4355,7 +4355,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
m_num = 0;
for (uint32_t ii = 0; ii < m_numTh; ++ii)
{
- TextureHandle handle = m_th[ii];
+ TextureHandle handle = m_attachment[ii].handle;
if (isValid(handle) )
{
const TextureD3D11& texture = s_renderD3D11->m_textures[handle.idx];
@@ -4404,7 +4404,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
: D3D11_DSV_DIMENSION_TEXTURE2D
;
dsvDesc.Flags = 0;
- dsvDesc.Texture2D.MipSlice = 0;
+ dsvDesc.Texture2D.MipSlice = m_attachment[ii].mip;
DX_CHECK(s_renderD3D11->m_device->CreateDepthStencilView(texture.m_ptr, &dsvDesc, &m_dsv) );
}
break;
@@ -4417,14 +4417,14 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY;
dsvDesc.Texture2DMSArray.ArraySize = 1;
- dsvDesc.Texture2DMSArray.FirstArraySlice = 0;
+ dsvDesc.Texture2DMSArray.FirstArraySlice = m_attachment[ii].layer;
}
else
{
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
dsvDesc.Texture2DArray.ArraySize = 1;
- dsvDesc.Texture2DArray.FirstArraySlice = 0;
- dsvDesc.Texture2DArray.MipSlice = 0;
+ dsvDesc.Texture2DArray.FirstArraySlice = m_attachment[ii].layer;
+ dsvDesc.Texture2DArray.MipSlice = m_attachment[ii].mip;
}
dsvDesc.Flags = 0;
DX_CHECK(s_renderD3D11->m_device->CreateDepthStencilView(texture.m_ptr, &dsvDesc, &m_dsv) );
@@ -4438,7 +4438,20 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{
default:
case TextureD3D11::Texture2D:
- DX_CHECK(s_renderD3D11->m_device->CreateRenderTargetView(texture.m_ptr, NULL, &m_rtv[m_num]) );
+ {
+ D3D11_RENDER_TARGET_VIEW_DESC desc;
+ desc.Format = s_textureFormat[texture.m_textureFormat].m_fmt;
+ if (1 < msaa.Count)
+ {
+ desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMS;
+ }
+ else
+ {
+ desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
+ desc.Texture2D.MipSlice = m_attachment[ii].mip;
+ }
+ DX_CHECK(s_renderD3D11->m_device->CreateRenderTargetView(texture.m_ptr, &desc, &m_rtv[m_num]) );
+ }
break;
case TextureD3D11::TextureCube:
@@ -4449,14 +4462,14 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{
desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY;
desc.Texture2DMSArray.ArraySize = 1;
- desc.Texture2DMSArray.FirstArraySlice = 0;
+ desc.Texture2DMSArray.FirstArraySlice = m_attachment[ii].layer;
}
else
{
desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
desc.Texture2DArray.ArraySize = 1;
- desc.Texture2DArray.FirstArraySlice = 0;
- desc.Texture2DArray.MipSlice = 0;
+ desc.Texture2DArray.FirstArraySlice = m_attachment[ii].layer;
+ desc.Texture2DArray.MipSlice = m_attachment[ii].mip;
}
DX_CHECK(s_renderD3D11->m_device->CreateRenderTargetView(texture.m_ptr, &desc, &m_rtv[m_num]) );
}
@@ -4467,9 +4480,9 @@ BX_PRAGMA_DIAGNOSTIC_POP();
D3D11_RENDER_TARGET_VIEW_DESC desc;
desc.Format = s_textureFormat[texture.m_textureFormat].m_fmt;
desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D;
- desc.Texture3D.MipSlice = 0;
+ desc.Texture3D.MipSlice = m_attachment[ii].mip;
desc.Texture3D.WSize = 1;
- desc.Texture3D.FirstWSlice = 0;
+ desc.Texture3D.FirstWSlice = m_attachment[ii].layer;
DX_CHECK(s_renderD3D11->m_device->CreateRenderTargetView(texture.m_ptr, &desc, &m_rtv[m_num]) );
}
break;
diff --git a/3rdparty/bgfx/src/renderer_d3d11.h b/3rdparty/bgfx/src/renderer_d3d11.h
index 151d3ce5cc7..833eda40e1a 100644
--- a/3rdparty/bgfx/src/renderer_d3d11.h
+++ b/3rdparty/bgfx/src/renderer_d3d11.h
@@ -261,7 +261,7 @@ namespace bgfx { namespace d3d11
{
}
- void create(uint8_t _num, const TextureHandle* _handles);
+ void create(uint8_t _num, const Attachment* _attachment);
void create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat);
uint16_t destroy();
void preReset(bool _force = false);
@@ -278,7 +278,7 @@ namespace bgfx { namespace d3d11
uint16_t m_denseIdx;
uint8_t m_num;
uint8_t m_numTh;
- TextureHandle m_th[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
+ Attachment m_attachment[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
};
struct TimerQueryD3D11
diff --git a/3rdparty/bgfx/src/renderer_d3d12.cpp b/3rdparty/bgfx/src/renderer_d3d12.cpp
index 76eb52e0e21..409d33bce10 100644
--- a/3rdparty/bgfx/src/renderer_d3d12.cpp
+++ b/3rdparty/bgfx/src/renderer_d3d12.cpp
@@ -1388,9 +1388,9 @@ namespace bgfx { namespace d3d12
m_textures[_handle.idx].destroy();
}
- void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const TextureHandle* _textureHandles) BX_OVERRIDE
+ void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const Attachment* _attachment) BX_OVERRIDE
{
- m_frameBuffers[_handle.idx].create(_num, _textureHandles);
+ m_frameBuffers[_handle.idx].create(_num, _attachment);
}
void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat) BX_OVERRIDE
@@ -4184,10 +4184,10 @@ data.NumQualityLevels = 0;
return _state;
}
- void FrameBufferD3D12::create(uint8_t _num, const TextureHandle* _handles)
+ void FrameBufferD3D12::create(uint8_t _num, const Attachment* _attachment)
{
m_numTh = _num;
- memcpy(m_th, _handles, _num*sizeof(TextureHandle) );
+ memcpy(m_attachment, _attachment, _num*sizeof(Attachment) );
postReset();
}
@@ -4217,7 +4217,7 @@ data.NumQualityLevels = 0;
m_num = 0;
for (uint32_t ii = 0; ii < m_numTh; ++ii)
{
- TextureHandle handle = m_th[ii];
+ TextureHandle handle = m_attachment[ii].handle;
if (isValid(handle) )
{
const TextureD3D12& texture = s_renderD3D12->m_textures[handle.idx];
diff --git a/3rdparty/bgfx/src/renderer_d3d12.h b/3rdparty/bgfx/src/renderer_d3d12.h
index d046b275142..39f165a03da 100644
--- a/3rdparty/bgfx/src/renderer_d3d12.h
+++ b/3rdparty/bgfx/src/renderer_d3d12.h
@@ -295,7 +295,7 @@ namespace bgfx { namespace d3d12
m_depth.idx = bgfx::invalidHandle;
}
- void create(uint8_t _num, const TextureHandle* _handles);
+ void create(uint8_t _num, const Attachment* _attachment);
void create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat);
uint16_t destroy();
void preReset();
@@ -311,7 +311,7 @@ namespace bgfx { namespace d3d12
uint16_t m_denseIdx;
uint8_t m_num;
uint8_t m_numTh;
- TextureHandle m_th[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
+ Attachment m_attachment[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
};
struct CommandQueueD3D12
diff --git a/3rdparty/bgfx/src/renderer_d3d9.cpp b/3rdparty/bgfx/src/renderer_d3d9.cpp
index 4fb4d435b4a..919a952260b 100644
--- a/3rdparty/bgfx/src/renderer_d3d9.cpp
+++ b/3rdparty/bgfx/src/renderer_d3d9.cpp
@@ -1018,9 +1018,9 @@ namespace bgfx { namespace d3d9
m_textures[_handle.idx].destroy();
}
- void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const TextureHandle* _textureHandles) BX_OVERRIDE
+ void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const Attachment* _attachment) BX_OVERRIDE
{
- m_frameBuffers[_handle.idx].create(_num, _textureHandles);
+ m_frameBuffers[_handle.idx].create(_num, _attachment);
}
void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat) BX_OVERRIDE
@@ -3062,7 +3062,7 @@ namespace bgfx { namespace d3d9
}
}
- void FrameBufferD3D9::create(uint8_t _num, const TextureHandle* _handles)
+ void FrameBufferD3D9::create(uint8_t _num, const Attachment* _attachment)
{
for (uint32_t ii = 0; ii < BX_COUNTOF(m_color); ++ii)
{
@@ -3074,7 +3074,7 @@ namespace bgfx { namespace d3d9
m_needResolve = false;
for (uint32_t ii = 0; ii < _num; ++ii)
{
- TextureHandle handle = _handles[ii];
+ TextureHandle handle = _attachment[ii].handle;
if (isValid(handle) )
{
const TextureD3D9& texture = s_renderD3D9->m_textures[handle.idx];
@@ -3102,7 +3102,7 @@ namespace bgfx { namespace d3d9
}
else
{
- m_color[m_num] = texture.getSurface();
+ m_color[m_num] = texture.getSurface(uint8_t(_attachment[ii].layer) );
}
m_num++;
}
diff --git a/3rdparty/bgfx/src/renderer_d3d9.h b/3rdparty/bgfx/src/renderer_d3d9.h
index aecfba57322..0b0e030dc5c 100644
--- a/3rdparty/bgfx/src/renderer_d3d9.h
+++ b/3rdparty/bgfx/src/renderer_d3d9.h
@@ -389,7 +389,7 @@ namespace bgfx { namespace d3d9
m_depthHandle.idx = invalidHandle;
}
- void create(uint8_t _num, const TextureHandle* _handles);
+ void create(uint8_t _num, const Attachment* _attachment);
void create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat);
uint16_t destroy();
HRESULT present();
diff --git a/3rdparty/bgfx/src/renderer_gl.cpp b/3rdparty/bgfx/src/renderer_gl.cpp
index ff6184ccc98..0feccaf9680 100644
--- a/3rdparty/bgfx/src/renderer_gl.cpp
+++ b/3rdparty/bgfx/src/renderer_gl.cpp
@@ -2243,9 +2243,9 @@ namespace bgfx { namespace gl
m_textures[_handle.idx].destroy();
}
- void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const TextureHandle* _textureHandles) BX_OVERRIDE
+ void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const Attachment* _attachment) BX_OVERRIDE
{
- m_frameBuffers[_handle.idx].create(_num, _textureHandles);
+ m_frameBuffers[_handle.idx].create(_num, _attachment);
}
void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat) BX_OVERRIDE
@@ -5017,12 +5017,12 @@ namespace bgfx { namespace gl
BX_UNUSED(complete);
}
- void FrameBufferGL::create(uint8_t _num, const TextureHandle* _handles)
+ void FrameBufferGL::create(uint8_t _num, const Attachment* _attachment)
{
GL_CHECK(glGenFramebuffers(1, &m_fbo[0]) );
m_numTh = _num;
- memcpy(m_th, _handles, _num*sizeof(TextureHandle) );
+ memcpy(m_attachment, _attachment, _num*sizeof(Attachment) );
postReset();
}
@@ -5040,15 +5040,15 @@ namespace bgfx { namespace gl
uint32_t colorIdx = 0;
for (uint32_t ii = 0; ii < m_numTh; ++ii)
{
- TextureHandle handle = m_th[ii];
+ TextureHandle handle = m_attachment[ii].handle;
if (isValid(handle) )
{
const TextureGL& texture = s_renderGL->m_textures[handle.idx];
if (0 == colorIdx)
{
- m_width = texture.m_width;
- m_height = texture.m_height;
+ m_width = bx::uint32_max(texture.m_width >> m_attachment[ii].mip, 1);
+ m_height = bx::uint32_max(texture.m_height >> m_attachment[ii].mip, 1);
}
GLenum attachment = GL_COLOR_ATTACHMENT0 + colorIdx;
@@ -5086,7 +5086,7 @@ namespace bgfx { namespace gl
else
{
GLenum target = GL_TEXTURE_CUBE_MAP == texture.m_target
- ? GL_TEXTURE_CUBE_MAP_POSITIVE_X
+ ? GL_TEXTURE_CUBE_MAP_POSITIVE_X + m_attachment[ii].layer
: texture.m_target
;
@@ -5094,7 +5094,7 @@ namespace bgfx { namespace gl
, attachment
, target
, texture.m_id
- , 0
+ , m_attachment[ii].mip
) );
}
@@ -5134,7 +5134,7 @@ namespace bgfx { namespace gl
colorIdx = 0;
for (uint32_t ii = 0; ii < m_numTh; ++ii)
{
- TextureHandle handle = m_th[ii];
+ TextureHandle handle = m_attachment[ii].handle;
if (isValid(handle) )
{
const TextureGL& texture = s_renderGL->m_textures[handle.idx];
@@ -5145,11 +5145,17 @@ namespace bgfx { namespace gl
if (!isDepth( (TextureFormat::Enum)texture.m_textureFormat) )
{
++colorIdx;
+
+ GLenum target = GL_TEXTURE_CUBE_MAP == texture.m_target
+ ? GL_TEXTURE_CUBE_MAP_POSITIVE_X + m_attachment[ii].layer
+ : texture.m_target
+ ;
+
GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER
, attachment
- , texture.m_target
+ , target
, texture.m_id
- , 0
+ , m_attachment[ii].mip
) );
}
}
diff --git a/3rdparty/bgfx/src/renderer_gl.h b/3rdparty/bgfx/src/renderer_gl.h
index 06b1525fd64..91c49c22f02 100644
--- a/3rdparty/bgfx/src/renderer_gl.h
+++ b/3rdparty/bgfx/src/renderer_gl.h
@@ -13,6 +13,7 @@
|| BX_PLATFORM_BSD \
|| BX_PLATFORM_QNX \
|| BX_PLATFORM_RPI \
+ || BX_PLATFORM_STEAMLINK \
|| BX_PLATFORM_WINDOWS \
) )
@@ -1169,7 +1170,7 @@ namespace bgfx { namespace gl
memset(m_fbo, 0, sizeof(m_fbo) );
}
- void create(uint8_t _num, const TextureHandle* _handles);
+ void create(uint8_t _num, const Attachment* _attachment);
void create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat);
void postReset();
uint16_t destroy();
@@ -1183,7 +1184,7 @@ namespace bgfx { namespace gl
uint16_t m_denseIdx;
uint8_t m_num;
uint8_t m_numTh;
- TextureHandle m_th[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
+ Attachment m_attachment[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
};
struct ProgramGL
diff --git a/3rdparty/bgfx/src/renderer_mtl.h b/3rdparty/bgfx/src/renderer_mtl.h
index 2b683cff891..f471ee5d457 100644
--- a/3rdparty/bgfx/src/renderer_mtl.h
+++ b/3rdparty/bgfx/src/renderer_mtl.h
@@ -694,7 +694,7 @@ namespace bgfx { namespace mtl
m_depthHandle.idx = invalidHandle;
}
- void create(uint8_t _num, const TextureHandle* _handles);
+ void create(uint8_t _num, const Attachment* _attachment);
void create(uint16_t _denseIdx, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat);
void postReset();
uint16_t destroy();
diff --git a/3rdparty/bgfx/src/renderer_mtl.mm b/3rdparty/bgfx/src/renderer_mtl.mm
index 833a53bea0d..08faee495f7 100644
--- a/3rdparty/bgfx/src/renderer_mtl.mm
+++ b/3rdparty/bgfx/src/renderer_mtl.mm
@@ -694,9 +694,9 @@ namespace bgfx { namespace mtl
m_textures[_handle.idx].destroy();
}
- void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const TextureHandle* _textureHandles) BX_OVERRIDE
+ void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const Attachment* _attachment) BX_OVERRIDE
{
- m_frameBuffers[_handle.idx].create(_num, _textureHandles);
+ m_frameBuffers[_handle.idx].create(_num, _attachment);
}
void createFrameBuffer(FrameBufferHandle _handle, void* _nwh, uint32_t _width, uint32_t _height, TextureFormat::Enum _depthFormat) BX_OVERRIDE
@@ -2079,12 +2079,12 @@ namespace bgfx { namespace mtl
: m_sampler, _stage);
}
- void FrameBufferMtl::create(uint8_t _num, const TextureHandle* _handles)
+ void FrameBufferMtl::create(uint8_t _num, const Attachment* _attachment)
{
m_num = 0;
for (uint32_t ii = 0; ii < _num; ++ii)
{
- TextureHandle handle = _handles[ii];
+ TextureHandle handle = _attachment[ii].handle;
if (isValid(handle) )
{
const TextureMtl& texture = s_renderMtl->m_textures[handle.idx];
diff --git a/3rdparty/bgfx/src/renderer_null.cpp b/3rdparty/bgfx/src/renderer_null.cpp
index a68e66f0d68..9b3de91416b 100644
--- a/3rdparty/bgfx/src/renderer_null.cpp
+++ b/3rdparty/bgfx/src/renderer_null.cpp
@@ -134,7 +134,7 @@ namespace bgfx { namespace noop
{
}
- void createFrameBuffer(FrameBufferHandle /*_handle*/, uint8_t /*_num*/, const TextureHandle* /*_textureHandles*/) BX_OVERRIDE
+ void createFrameBuffer(FrameBufferHandle /*_handle*/, uint8_t /*_num*/, const Attachment* /*_attachment*/) BX_OVERRIDE
{
}