mirror of https://github.com/bkaradzic/bgfx
Added access parameter for frame buffer attachment.
This commit is contained in:
parent
5ba94e7458
commit
7639c5688c
|
@ -866,6 +866,9 @@ namespace bgfx
|
||||||
///
|
///
|
||||||
struct Attachment
|
struct Attachment
|
||||||
{
|
{
|
||||||
|
void init(TextureHandle _handle, Access::Enum _access = Access::Write, uint16_t _layer = 0, uint16_t _mip = 0, uint8_t _resolve = BGFX_RESOLVE_AUTO_GEN_MIPS);
|
||||||
|
|
||||||
|
Access::Enum access; //!<
|
||||||
TextureHandle handle; //!< Texture handle.
|
TextureHandle handle; //!< Texture handle.
|
||||||
uint16_t mip; //!< Mip level.
|
uint16_t mip; //!< Mip level.
|
||||||
uint16_t layer; //!< Cubemap side or depth layer/slice.
|
uint16_t layer; //!< Cubemap side or depth layer/slice.
|
||||||
|
|
|
@ -483,6 +483,7 @@ typedef struct bgfx_uniform_info_s
|
||||||
/**/
|
/**/
|
||||||
typedef struct bgfx_attachment_s
|
typedef struct bgfx_attachment_s
|
||||||
{
|
{
|
||||||
|
bgfx_access_t access;
|
||||||
bgfx_texture_handle_t handle;
|
bgfx_texture_handle_t handle;
|
||||||
uint16_t mip;
|
uint16_t mip;
|
||||||
uint16_t layer;
|
uint16_t layer;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#ifndef BGFX_DEFINES_H_HEADER_GUARD
|
#ifndef BGFX_DEFINES_H_HEADER_GUARD
|
||||||
#define BGFX_DEFINES_H_HEADER_GUARD
|
#define BGFX_DEFINES_H_HEADER_GUARD
|
||||||
|
|
||||||
#define BGFX_API_VERSION UINT32_C(89)
|
#define BGFX_API_VERSION UINT32_C(90)
|
||||||
|
|
||||||
/// Color RGB/alpha/depth write. When it's not specified write will be disabled.
|
/// Color RGB/alpha/depth write. When it's not specified write will be disabled.
|
||||||
#define BGFX_STATE_WRITE_R UINT64_C(0x0000000000000001) //!< Enable R write.
|
#define BGFX_STATE_WRITE_R UINT64_C(0x0000000000000001) //!< Enable R write.
|
||||||
|
|
14
src/bgfx.cpp
14
src/bgfx.cpp
|
@ -3104,6 +3104,15 @@ namespace bgfx
|
||||||
limits.transientIbSize = BGFX_CONFIG_TRANSIENT_INDEX_BUFFER_SIZE;
|
limits.transientIbSize = BGFX_CONFIG_TRANSIENT_INDEX_BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Attachment::init(TextureHandle _handle, Access::Enum _access, uint16_t _layer, uint16_t _mip, uint8_t _resolve)
|
||||||
|
{
|
||||||
|
access = _access;
|
||||||
|
handle = _handle;
|
||||||
|
mip = _mip;
|
||||||
|
layer = _layer;
|
||||||
|
resolve = _resolve;
|
||||||
|
}
|
||||||
|
|
||||||
bool init(const Init& _init)
|
bool init(const Init& _init)
|
||||||
{
|
{
|
||||||
if (NULL != s_ctx)
|
if (NULL != s_ctx)
|
||||||
|
@ -4288,10 +4297,7 @@ namespace bgfx
|
||||||
for (uint8_t ii = 0; ii < _num; ++ii)
|
for (uint8_t ii = 0; ii < _num; ++ii)
|
||||||
{
|
{
|
||||||
Attachment& at = attachment[ii];
|
Attachment& at = attachment[ii];
|
||||||
at.handle = _handles[ii];
|
at.init(_handles[ii], Access::Write, 0, 0, BGFX_RESOLVE_AUTO_GEN_MIPS);
|
||||||
at.mip = 0;
|
|
||||||
at.layer = 0;
|
|
||||||
at.resolve = BGFX_RESOLVE_AUTO_GEN_MIPS;
|
|
||||||
}
|
}
|
||||||
return createFrameBuffer(_num, attachment, _destroyTextures);
|
return createFrameBuffer(_num, attachment, _destroyTextures);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4673,10 +4673,11 @@ namespace bgfx { namespace d3d11
|
||||||
m_num = 0;
|
m_num = 0;
|
||||||
for (uint32_t ii = 0; ii < m_numTh; ++ii)
|
for (uint32_t ii = 0; ii < m_numTh; ++ii)
|
||||||
{
|
{
|
||||||
TextureHandle handle = m_attachment[ii].handle;
|
const Attachment& at = m_attachment[ii];
|
||||||
if (isValid(handle) )
|
|
||||||
|
if (isValid(at.handle) )
|
||||||
{
|
{
|
||||||
const TextureD3D11& texture = s_renderD3D11->m_textures[handle.idx];
|
const TextureD3D11& texture = s_renderD3D11->m_textures[at.handle.idx];
|
||||||
|
|
||||||
if (0 == m_width)
|
if (0 == m_width)
|
||||||
{
|
{
|
||||||
|
@ -4722,7 +4723,7 @@ namespace bgfx { namespace d3d11
|
||||||
: D3D11_DSV_DIMENSION_TEXTURE2D
|
: D3D11_DSV_DIMENSION_TEXTURE2D
|
||||||
;
|
;
|
||||||
dsvDesc.Flags = 0;
|
dsvDesc.Flags = 0;
|
||||||
dsvDesc.Texture2D.MipSlice = m_attachment[ii].mip;
|
dsvDesc.Texture2D.MipSlice = at.mip;
|
||||||
DX_CHECK(s_renderD3D11->m_device->CreateDepthStencilView(
|
DX_CHECK(s_renderD3D11->m_device->CreateDepthStencilView(
|
||||||
NULL == texture.m_rt ? texture.m_ptr : texture.m_rt
|
NULL == texture.m_rt ? texture.m_ptr : texture.m_rt
|
||||||
, &dsvDesc
|
, &dsvDesc
|
||||||
|
@ -4739,14 +4740,14 @@ namespace bgfx { namespace d3d11
|
||||||
{
|
{
|
||||||
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY;
|
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY;
|
||||||
dsvDesc.Texture2DMSArray.ArraySize = 1;
|
dsvDesc.Texture2DMSArray.ArraySize = 1;
|
||||||
dsvDesc.Texture2DMSArray.FirstArraySlice = m_attachment[ii].layer;
|
dsvDesc.Texture2DMSArray.FirstArraySlice = at.layer;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
|
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
|
||||||
dsvDesc.Texture2DArray.ArraySize = 1;
|
dsvDesc.Texture2DArray.ArraySize = 1;
|
||||||
dsvDesc.Texture2DArray.FirstArraySlice = m_attachment[ii].layer;
|
dsvDesc.Texture2DArray.FirstArraySlice = at.layer;
|
||||||
dsvDesc.Texture2DArray.MipSlice = m_attachment[ii].mip;
|
dsvDesc.Texture2DArray.MipSlice = at.mip;
|
||||||
}
|
}
|
||||||
dsvDesc.Flags = 0;
|
dsvDesc.Flags = 0;
|
||||||
DX_CHECK(s_renderD3D11->m_device->CreateDepthStencilView(texture.m_ptr, &dsvDesc, &m_dsv) );
|
DX_CHECK(s_renderD3D11->m_device->CreateDepthStencilView(texture.m_ptr, &dsvDesc, &m_dsv) );
|
||||||
|
@ -4754,7 +4755,7 @@ namespace bgfx { namespace d3d11
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (Access::Write == at.access)
|
||||||
{
|
{
|
||||||
D3D11_RENDER_TARGET_VIEW_DESC desc;
|
D3D11_RENDER_TARGET_VIEW_DESC desc;
|
||||||
desc.Format = texture.getSrvFormat();
|
desc.Format = texture.getSrvFormat();
|
||||||
|
@ -4767,7 +4768,7 @@ namespace bgfx { namespace d3d11
|
||||||
if (1 < texture.m_depth)
|
if (1 < texture.m_depth)
|
||||||
{
|
{
|
||||||
desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY;
|
desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY;
|
||||||
desc.Texture2DMSArray.FirstArraySlice = m_attachment[ii].layer;
|
desc.Texture2DMSArray.FirstArraySlice = at.layer;
|
||||||
desc.Texture2DMSArray.ArraySize = 1;
|
desc.Texture2DMSArray.ArraySize = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -4780,14 +4781,14 @@ namespace bgfx { namespace d3d11
|
||||||
if (1 < texture.m_depth)
|
if (1 < texture.m_depth)
|
||||||
{
|
{
|
||||||
desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
|
desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
|
||||||
desc.Texture2DArray.FirstArraySlice = m_attachment[ii].layer;
|
desc.Texture2DArray.FirstArraySlice = at.layer;
|
||||||
desc.Texture2DArray.ArraySize = 1;
|
desc.Texture2DArray.ArraySize = 1;
|
||||||
desc.Texture2DArray.MipSlice = m_attachment[ii].mip;
|
desc.Texture2DArray.MipSlice = at.mip;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||||
desc.Texture2D.MipSlice = m_attachment[ii].mip;
|
desc.Texture2D.MipSlice = at.mip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4803,23 +4804,23 @@ namespace bgfx { namespace d3d11
|
||||||
{
|
{
|
||||||
desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY;
|
desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY;
|
||||||
desc.Texture2DMSArray.ArraySize = 1;
|
desc.Texture2DMSArray.ArraySize = 1;
|
||||||
desc.Texture2DMSArray.FirstArraySlice = m_attachment[ii].layer;
|
desc.Texture2DMSArray.FirstArraySlice = at.layer;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
|
desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
|
||||||
desc.Texture2DArray.ArraySize = 1;
|
desc.Texture2DArray.ArraySize = 1;
|
||||||
desc.Texture2DArray.FirstArraySlice = m_attachment[ii].layer;
|
desc.Texture2DArray.FirstArraySlice = at.layer;
|
||||||
desc.Texture2DArray.MipSlice = m_attachment[ii].mip;
|
desc.Texture2DArray.MipSlice = at.mip;
|
||||||
}
|
}
|
||||||
DX_CHECK(s_renderD3D11->m_device->CreateRenderTargetView(texture.m_ptr, &desc, &m_rtv[m_num]) );
|
DX_CHECK(s_renderD3D11->m_device->CreateRenderTargetView(texture.m_ptr, &desc, &m_rtv[m_num]) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TextureD3D11::Texture3D:
|
case TextureD3D11::Texture3D:
|
||||||
desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D;
|
desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D;
|
||||||
desc.Texture3D.MipSlice = m_attachment[ii].mip;
|
desc.Texture3D.MipSlice = at.mip;
|
||||||
desc.Texture3D.WSize = 1;
|
desc.Texture3D.WSize = 1;
|
||||||
desc.Texture3D.FirstWSlice = m_attachment[ii].layer;
|
desc.Texture3D.FirstWSlice = at.layer;
|
||||||
DX_CHECK(s_renderD3D11->m_device->CreateRenderTargetView(texture.m_ptr, &desc, &m_rtv[m_num]) );
|
DX_CHECK(s_renderD3D11->m_device->CreateRenderTargetView(texture.m_ptr, &desc, &m_rtv[m_num]) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4827,6 +4828,10 @@ namespace bgfx { namespace d3d11
|
||||||
DX_CHECK(s_renderD3D11->m_device->CreateShaderResourceView(texture.m_ptr, NULL, &m_srv[m_num]) );
|
DX_CHECK(s_renderD3D11->m_device->CreateShaderResourceView(texture.m_ptr, NULL, &m_srv[m_num]) );
|
||||||
m_num++;
|
m_num++;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BX_CHECK(false, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4839,6 +4844,7 @@ namespace bgfx { namespace d3d11
|
||||||
for (uint32_t ii = 0; ii < m_numTh; ++ii)
|
for (uint32_t ii = 0; ii < m_numTh; ++ii)
|
||||||
{
|
{
|
||||||
const Attachment& at = m_attachment[ii];
|
const Attachment& at = m_attachment[ii];
|
||||||
|
|
||||||
if (isValid(at.handle) )
|
if (isValid(at.handle) )
|
||||||
{
|
{
|
||||||
const TextureD3D11& texture = s_renderD3D11->m_textures[at.handle.idx];
|
const TextureD3D11& texture = s_renderD3D11->m_textures[at.handle.idx];
|
||||||
|
|
|
@ -5070,10 +5070,11 @@ namespace bgfx { namespace d3d12
|
||||||
m_num = 0;
|
m_num = 0;
|
||||||
for (uint32_t ii = 0; ii < m_numTh; ++ii)
|
for (uint32_t ii = 0; ii < m_numTh; ++ii)
|
||||||
{
|
{
|
||||||
TextureHandle handle = m_attachment[ii].handle;
|
const Attachment& at = m_attachment[ii];
|
||||||
if (isValid(handle) )
|
|
||||||
|
if (isValid(at.handle) )
|
||||||
{
|
{
|
||||||
const TextureD3D12& texture = s_renderD3D12->m_textures[handle.idx];
|
const TextureD3D12& texture = s_renderD3D12->m_textures[at.handle.idx];
|
||||||
|
|
||||||
if (0 == m_width)
|
if (0 == m_width)
|
||||||
{
|
{
|
||||||
|
@ -5085,7 +5086,7 @@ namespace bgfx { namespace d3d12
|
||||||
if (bimg::isDepth(bimg::TextureFormat::Enum(texture.m_textureFormat) ) )
|
if (bimg::isDepth(bimg::TextureFormat::Enum(texture.m_textureFormat) ) )
|
||||||
{
|
{
|
||||||
BX_CHECK(!isValid(m_depth), "");
|
BX_CHECK(!isValid(m_depth), "");
|
||||||
m_depth = handle;
|
m_depth = at.handle;
|
||||||
D3D12_CPU_DESCRIPTOR_HANDLE dsvDescriptor = getCPUHandleHeapStart(s_renderD3D12->m_dsvDescriptorHeap);
|
D3D12_CPU_DESCRIPTOR_HANDLE dsvDescriptor = getCPUHandleHeapStart(s_renderD3D12->m_dsvDescriptorHeap);
|
||||||
uint32_t dsvDescriptorSize = device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_DSV);
|
uint32_t dsvDescriptorSize = device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_DSV);
|
||||||
dsvDescriptor.ptr += (1 + fbhIdx) * dsvDescriptorSize;
|
dsvDescriptor.ptr += (1 + fbhIdx) * dsvDescriptorSize;
|
||||||
|
@ -5116,9 +5117,9 @@ namespace bgfx { namespace d3d12
|
||||||
, NULL
|
, NULL
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else if (Access::Write == at.access)
|
||||||
{
|
{
|
||||||
m_texture[m_num] = handle;
|
m_texture[m_num] = at.handle;
|
||||||
D3D12_CPU_DESCRIPTOR_HANDLE rtv = { rtvDescriptor.ptr + m_num * rtvDescriptorSize };
|
D3D12_CPU_DESCRIPTOR_HANDLE rtv = { rtvDescriptor.ptr + m_num * rtvDescriptorSize };
|
||||||
|
|
||||||
D3D12_RENDER_TARGET_VIEW_DESC desc;
|
D3D12_RENDER_TARGET_VIEW_DESC desc;
|
||||||
|
@ -5135,7 +5136,7 @@ namespace bgfx { namespace d3d12
|
||||||
// else
|
// else
|
||||||
{
|
{
|
||||||
desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
|
desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
|
||||||
desc.Texture2D.MipSlice = m_attachment[ii].mip;
|
desc.Texture2D.MipSlice = at.mip;
|
||||||
desc.Texture2D.PlaneSlice = 0;
|
desc.Texture2D.PlaneSlice = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -5145,23 +5146,23 @@ namespace bgfx { namespace d3d12
|
||||||
// {
|
// {
|
||||||
// desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY;
|
// desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY;
|
||||||
// desc.Texture2DMSArray.ArraySize = 1;
|
// desc.Texture2DMSArray.ArraySize = 1;
|
||||||
// desc.Texture2DMSArray.FirstArraySlice = m_attachment[ii].layer;
|
// desc.Texture2DMSArray.FirstArraySlice = at.layer;
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
{
|
{
|
||||||
desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DARRAY;
|
desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DARRAY;
|
||||||
desc.Texture2DArray.ArraySize = 1;
|
desc.Texture2DArray.ArraySize = 1;
|
||||||
desc.Texture2DArray.FirstArraySlice = m_attachment[ii].layer;
|
desc.Texture2DArray.FirstArraySlice = at.layer;
|
||||||
desc.Texture2DArray.MipSlice = m_attachment[ii].mip;
|
desc.Texture2DArray.MipSlice = at.mip;
|
||||||
desc.Texture2DArray.PlaneSlice = 0;
|
desc.Texture2DArray.PlaneSlice = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TextureD3D12::Texture3D:
|
case TextureD3D12::Texture3D:
|
||||||
desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE3D;
|
desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE3D;
|
||||||
desc.Texture3D.MipSlice = m_attachment[ii].mip;
|
desc.Texture3D.MipSlice = at.mip;
|
||||||
desc.Texture3D.WSize = 1;
|
desc.Texture3D.WSize = 1;
|
||||||
desc.Texture3D.FirstWSlice = m_attachment[ii].layer;
|
desc.Texture3D.FirstWSlice = at.layer;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5180,6 +5181,10 @@ namespace bgfx { namespace d3d12
|
||||||
|
|
||||||
m_num++;
|
m_num++;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BX_CHECK(false, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5192,6 +5197,7 @@ namespace bgfx { namespace d3d12
|
||||||
for (uint32_t ii = 0; ii < m_numTh; ++ii)
|
for (uint32_t ii = 0; ii < m_numTh; ++ii)
|
||||||
{
|
{
|
||||||
const Attachment& at = m_attachment[ii];
|
const Attachment& at = m_attachment[ii];
|
||||||
|
|
||||||
if (isValid(at.handle) )
|
if (isValid(at.handle) )
|
||||||
{
|
{
|
||||||
const TextureD3D12& texture = s_renderD3D12->m_textures[at.handle.idx];
|
const TextureD3D12& texture = s_renderD3D12->m_textures[at.handle.idx];
|
||||||
|
|
|
@ -3197,10 +3197,11 @@ namespace bgfx { namespace d3d9
|
||||||
|
|
||||||
for (uint32_t ii = 0; ii < _num; ++ii)
|
for (uint32_t ii = 0; ii < _num; ++ii)
|
||||||
{
|
{
|
||||||
TextureHandle handle = m_attachment[ii].handle;
|
const Attachment& at = m_attachment[ii];
|
||||||
if (isValid(handle) )
|
|
||||||
|
if (isValid(at.handle) )
|
||||||
{
|
{
|
||||||
const TextureD3D9& texture = s_renderD3D9->m_textures[handle.idx];
|
const TextureD3D9& texture = s_renderD3D9->m_textures[at.handle.idx];
|
||||||
|
|
||||||
if (NULL != texture.m_surface)
|
if (NULL != texture.m_surface)
|
||||||
{
|
{
|
||||||
|
@ -3209,7 +3210,7 @@ namespace bgfx { namespace d3d9
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_surface[ii] = texture.getSurface(uint8_t(m_attachment[ii].layer), uint8_t(m_attachment[ii].mip) );
|
m_surface[ii] = texture.getSurface(uint8_t(at.layer), uint8_t(at.mip) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == m_num)
|
if (0 == m_num)
|
||||||
|
@ -3386,19 +3387,24 @@ namespace bgfx { namespace d3d9
|
||||||
{
|
{
|
||||||
for (uint32_t ii = 0, num = m_numTh; ii < num; ++ii)
|
for (uint32_t ii = 0, num = m_numTh; ii < num; ++ii)
|
||||||
{
|
{
|
||||||
TextureHandle th = m_attachment[ii].handle;
|
const Attachment& at = m_attachment[ii];
|
||||||
|
|
||||||
if (isValid(th) )
|
if (isValid(at.handle) )
|
||||||
{
|
{
|
||||||
TextureD3D9& texture = s_renderD3D9->m_textures[th.idx];
|
TextureD3D9& texture = s_renderD3D9->m_textures[at.handle.idx];
|
||||||
|
|
||||||
if (NULL != texture.m_surface)
|
if (NULL != texture.m_surface)
|
||||||
{
|
{
|
||||||
m_surface[ii] = texture.m_surface;
|
m_surface[ii] = texture.m_surface;
|
||||||
m_surface[ii]->AddRef();
|
m_surface[ii]->AddRef();
|
||||||
}
|
}
|
||||||
|
else if (Access::Write == at.access)
|
||||||
|
{
|
||||||
|
m_surface[ii] = texture.getSurface(uint8_t(at.layer), uint8_t(at.mip) );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_surface[ii] = texture.getSurface(uint8_t(m_attachment[ii].layer), uint8_t(m_attachment[ii].mip) );
|
BX_CHECK(false, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5875,15 +5875,16 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
|
||||||
uint32_t colorIdx = 0;
|
uint32_t colorIdx = 0;
|
||||||
for (uint32_t ii = 0; ii < m_numTh; ++ii)
|
for (uint32_t ii = 0; ii < m_numTh; ++ii)
|
||||||
{
|
{
|
||||||
TextureHandle handle = m_attachment[ii].handle;
|
const Attachment& at = m_attachment[ii];
|
||||||
if (isValid(handle) )
|
|
||||||
|
if (isValid(at.handle) )
|
||||||
{
|
{
|
||||||
const TextureGL& texture = s_renderGL->m_textures[handle.idx];
|
const TextureGL& texture = s_renderGL->m_textures[at.handle.idx];
|
||||||
|
|
||||||
if (0 == colorIdx)
|
if (0 == colorIdx)
|
||||||
{
|
{
|
||||||
m_width = bx::uint32_max(texture.m_width >> m_attachment[ii].mip, 1);
|
m_width = bx::uint32_max(texture.m_width >> at.mip, 1);
|
||||||
m_height = bx::uint32_max(texture.m_height >> m_attachment[ii].mip, 1);
|
m_height = bx::uint32_max(texture.m_height >> at.mip, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLenum attachment = GL_COLOR_ATTACHMENT0 + colorIdx;
|
GLenum attachment = GL_COLOR_ATTACHMENT0 + colorIdx;
|
||||||
|
@ -5936,7 +5937,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (Access::Write == at.access)
|
||||||
{
|
{
|
||||||
if (1 < texture.m_depth
|
if (1 < texture.m_depth
|
||||||
&& !texture.isCubeMap())
|
&& !texture.isCubeMap())
|
||||||
|
@ -5944,14 +5945,14 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
|
||||||
GL_CHECK(glFramebufferTextureLayer(GL_FRAMEBUFFER
|
GL_CHECK(glFramebufferTextureLayer(GL_FRAMEBUFFER
|
||||||
, attachment
|
, attachment
|
||||||
, texture.m_id
|
, texture.m_id
|
||||||
, m_attachment[ii].mip
|
, at.mip
|
||||||
, m_attachment[ii].layer
|
, at.layer
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GLenum target = texture.isCubeMap()
|
GLenum target = texture.isCubeMap()
|
||||||
? GL_TEXTURE_CUBE_MAP_POSITIVE_X + m_attachment[ii].layer
|
? GL_TEXTURE_CUBE_MAP_POSITIVE_X + at.layer
|
||||||
: texture.m_target
|
: texture.m_target
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -5959,10 +5960,14 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
|
||||||
, attachment
|
, attachment
|
||||||
, target
|
, target
|
||||||
, texture.m_id
|
, texture.m_id
|
||||||
, m_attachment[ii].mip
|
, at.mip
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BX_CHECK(false, "");
|
||||||
|
}
|
||||||
|
|
||||||
needResolve |= (0 != texture.m_rbo) && (0 != texture.m_id);
|
needResolve |= (0 != texture.m_rbo) && (0 != texture.m_id);
|
||||||
}
|
}
|
||||||
|
@ -6000,10 +6005,11 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
|
||||||
colorIdx = 0;
|
colorIdx = 0;
|
||||||
for (uint32_t ii = 0; ii < m_numTh; ++ii)
|
for (uint32_t ii = 0; ii < m_numTh; ++ii)
|
||||||
{
|
{
|
||||||
TextureHandle handle = m_attachment[ii].handle;
|
const Attachment& at = m_attachment[ii];
|
||||||
if (isValid(handle) )
|
|
||||||
|
if (isValid(at.handle) )
|
||||||
{
|
{
|
||||||
const TextureGL& texture = s_renderGL->m_textures[handle.idx];
|
const TextureGL& texture = s_renderGL->m_textures[at.handle.idx];
|
||||||
|
|
||||||
if (0 != texture.m_id)
|
if (0 != texture.m_id)
|
||||||
{
|
{
|
||||||
|
@ -6013,7 +6019,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
|
||||||
++colorIdx;
|
++colorIdx;
|
||||||
|
|
||||||
GLenum target = texture.isCubeMap()
|
GLenum target = texture.isCubeMap()
|
||||||
? GL_TEXTURE_CUBE_MAP_POSITIVE_X + m_attachment[ii].layer
|
? GL_TEXTURE_CUBE_MAP_POSITIVE_X + at.layer
|
||||||
: texture.m_target
|
: texture.m_target
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -6021,7 +6027,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
|
||||||
, attachment
|
, attachment
|
||||||
, target
|
, target
|
||||||
, texture.m_id
|
, texture.m_id
|
||||||
, m_attachment[ii].mip
|
, at.mip
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6076,10 +6082,11 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
|
||||||
uint32_t colorIdx = 0;
|
uint32_t colorIdx = 0;
|
||||||
for (uint32_t ii = 0; ii < m_numTh; ++ii)
|
for (uint32_t ii = 0; ii < m_numTh; ++ii)
|
||||||
{
|
{
|
||||||
TextureHandle handle = m_attachment[ii].handle;
|
const Attachment& at = m_attachment[ii];
|
||||||
if (isValid(handle) )
|
|
||||||
|
if (isValid(at.handle) )
|
||||||
{
|
{
|
||||||
const TextureGL& texture = s_renderGL->m_textures[handle.idx];
|
const TextureGL& texture = s_renderGL->m_textures[at.handle.idx];
|
||||||
|
|
||||||
bimg::TextureFormat::Enum format = bimg::TextureFormat::Enum(texture.m_textureFormat);
|
bimg::TextureFormat::Enum format = bimg::TextureFormat::Enum(texture.m_textureFormat);
|
||||||
if (!bimg::isDepth(format) )
|
if (!bimg::isDepth(format) )
|
||||||
|
@ -6112,6 +6119,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) );
|
||||||
for (uint32_t ii = 0; ii < m_numTh; ++ii)
|
for (uint32_t ii = 0; ii < m_numTh; ++ii)
|
||||||
{
|
{
|
||||||
const Attachment& at = m_attachment[ii];
|
const Attachment& at = m_attachment[ii];
|
||||||
|
|
||||||
if (isValid(at.handle) )
|
if (isValid(at.handle) )
|
||||||
{
|
{
|
||||||
const TextureGL& texture = s_renderGL->m_textures[at.handle.idx];
|
const TextureGL& texture = s_renderGL->m_textures[at.handle.idx];
|
||||||
|
|
Loading…
Reference in New Issue