Added framebuffer attachment.
This commit is contained in:
parent
8005ec0687
commit
459e211a26
@ -3572,3 +3572,10 @@ bool imguiMouseOverArea()
|
||||
{
|
||||
return s_imgui.m_insideArea;
|
||||
}
|
||||
|
||||
bgfx::ProgramHandle imguiGetImageProgram(uint8_t _mip)
|
||||
{
|
||||
const float lodEnabled[4] = { float(_mip), 1.0f, 0.0f, 0.0f };
|
||||
bgfx::setUniform(s_imgui.u_imageLodEnabled, lodEnabled);
|
||||
return s_imgui.m_imageProgram;
|
||||
}
|
||||
|
@ -208,12 +208,13 @@ bool imguiMouseOverArea();
|
||||
|
||||
namespace ImGui
|
||||
{
|
||||
#define IMGUI_FLAGS_NONE UINT16_C(0x0000)
|
||||
#define IMGUI_FLAGS_ALPHA_BLEND UINT16_C(0x0001)
|
||||
#define IMGUI_FLAGS_NONE UINT8_C(0x00)
|
||||
#define IMGUI_FLAGS_ALPHA_BLEND UINT8_C(0x01)
|
||||
|
||||
// Helper function for passing bgfx::TextureHandle to ImGui::Image.
|
||||
inline void Image(bgfx::TextureHandle _handle
|
||||
, uint16_t _flags
|
||||
, uint8_t _flags
|
||||
, uint8_t _mip
|
||||
, const ImVec2& _size
|
||||
, const ImVec2& _uv0 = ImVec2(0.0f, 0.0f)
|
||||
, const ImVec2& _uv1 = ImVec2(1.0f, 1.0f)
|
||||
@ -221,9 +222,10 @@ namespace ImGui
|
||||
, const ImVec4& _borderCol = ImVec4(0.0f, 0.0f, 0.0f, 0.0f)
|
||||
)
|
||||
{
|
||||
union { struct { uint16_t flags; bgfx::TextureHandle handle; } s; ImTextureID ptr; } texture;
|
||||
texture.s.flags = _flags;
|
||||
union { struct { bgfx::TextureHandle handle; uint8_t flags; uint8_t mip; } s; ImTextureID ptr; } texture;
|
||||
texture.s.handle = _handle;
|
||||
texture.s.flags = _flags;
|
||||
texture.s.mip = _mip;
|
||||
Image(texture.ptr, _size, _uv0, _uv1, _tintCol, _borderCol);
|
||||
}
|
||||
|
||||
@ -236,12 +238,13 @@ namespace ImGui
|
||||
, const ImVec4& _borderCol = ImVec4(0.0f, 0.0f, 0.0f, 0.0f)
|
||||
)
|
||||
{
|
||||
Image(_handle, IMGUI_FLAGS_ALPHA_BLEND, _size, _uv0, _uv1, _tintCol, _borderCol);
|
||||
Image(_handle, IMGUI_FLAGS_ALPHA_BLEND, 0, _size, _uv0, _uv1, _tintCol, _borderCol);
|
||||
}
|
||||
|
||||
// Helper function for passing bgfx::TextureHandle to ImGui::ImageButton.
|
||||
inline bool ImageButton(bgfx::TextureHandle _handle
|
||||
, uint16_t _flags
|
||||
, uint8_t _flags
|
||||
, uint8_t _mip
|
||||
, const ImVec2& _size
|
||||
, const ImVec2& _uv0 = ImVec2(0.0f, 0.0f)
|
||||
, const ImVec2& _uv1 = ImVec2(1.0f, 1.0f)
|
||||
@ -250,9 +253,10 @@ namespace ImGui
|
||||
, const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f)
|
||||
)
|
||||
{
|
||||
union { struct { uint16_t flags; bgfx::TextureHandle handle; } s; ImTextureID ptr; } texture;
|
||||
texture.s.flags = _flags;
|
||||
union { struct { bgfx::TextureHandle handle; uint8_t flags; uint8_t mip; } s; ImTextureID ptr; } texture;
|
||||
texture.s.handle = _handle;
|
||||
texture.s.flags = _flags;
|
||||
texture.s.mip = _mip;
|
||||
return ImageButton(texture.ptr, _size, _uv0, _uv1, _framePadding, _bgCol, _tintCol);
|
||||
}
|
||||
|
||||
@ -266,7 +270,7 @@ namespace ImGui
|
||||
, const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f)
|
||||
)
|
||||
{
|
||||
return ImageButton(_handle, IMGUI_FLAGS_ALPHA_BLEND, _size, _uv0, _uv1, _framePadding, _bgCol, _tintCol);
|
||||
return ImageButton(_handle, IMGUI_FLAGS_ALPHA_BLEND, 0, _size, _uv0, _uv1, _framePadding, _bgCol, _tintCol);
|
||||
}
|
||||
|
||||
} // namespace ImGui
|
||||
|
@ -305,15 +305,21 @@ struct OcornutImguiContext
|
||||
;
|
||||
|
||||
bgfx::TextureHandle th = m_texture;
|
||||
bgfx::ProgramHandle program = m_program;
|
||||
|
||||
if (NULL != cmd->TextureId)
|
||||
{
|
||||
union { ImTextureID ptr; struct { uint16_t flags; bgfx::TextureHandle handle; } s; } texture = { cmd->TextureId };
|
||||
union { ImTextureID ptr; struct { bgfx::TextureHandle handle; uint8_t flags; uint8_t mip; } s; } texture = { cmd->TextureId };
|
||||
state |= 0 != (IMGUI_FLAGS_ALPHA_BLEND & texture.s.flags)
|
||||
? BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA)
|
||||
: BGFX_STATE_NONE
|
||||
;
|
||||
th = texture.s.handle;
|
||||
if (0 != texture.s.mip)
|
||||
{
|
||||
extern bgfx::ProgramHandle imguiGetImageProgram(uint8_t _mip);
|
||||
program = imguiGetImageProgram(texture.s.mip);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -331,7 +337,7 @@ struct OcornutImguiContext
|
||||
bgfx::setTexture(0, s_tex, th);
|
||||
bgfx::setVertexBuffer(&tvb, 0, numVertices);
|
||||
bgfx::setIndexBuffer(&tib, offset, cmd->ElemCount);
|
||||
bgfx::submit(cmd->ViewId, m_program);
|
||||
bgfx::submit(cmd->ViewId, program);
|
||||
}
|
||||
|
||||
offset += cmd->ElemCount;
|
||||
|
@ -532,6 +532,14 @@ namespace bgfx
|
||||
bool cubeMap; //!< Texture is cubemap.
|
||||
};
|
||||
|
||||
///
|
||||
struct Attachment
|
||||
{
|
||||
TextureHandle handle; //!< Texture handle.
|
||||
uint16_t mip; //!< Mip level.
|
||||
uint16_t layer; //!< Cubemap side or depth layer/slice.
|
||||
};
|
||||
|
||||
/// Transform data.
|
||||
///
|
||||
/// @attention C99 equivalent is `bgfx_transform_t`.
|
||||
@ -1362,7 +1370,7 @@ namespace bgfx
|
||||
/// Update Cube texture.
|
||||
///
|
||||
/// @param[in] _handle Texture handle.
|
||||
/// @param[in] _side Cubemap side `BGFX_CUBE_MAP_<POSITIVE or NEGATIVE>_<AXIS>`,
|
||||
/// @param[in] _side Cubemap side `BGFX_CUBE_MAP_<POSITIVE or NEGATIVE>_<X, Y or Z>`,
|
||||
/// where 0 is +X, 1 is -X, 2 is +Y, 3 is -Y, 4 is +Z, and 5 is -Z.
|
||||
///
|
||||
/// +----------+
|
||||
@ -1473,15 +1481,13 @@ namespace bgfx
|
||||
/// Create frame buffer.
|
||||
///
|
||||
/// @param[in] _num Number of texture attachments.
|
||||
/// @param[in] _handles Texture attachments.
|
||||
/// @param[in] _side Side for cubemap texture attachements.
|
||||
/// See: `BGFX_CUBE_MAP_<POSITIVE or NEGATIVE>_<AXIS>`.
|
||||
/// @param[in] _attachment Attachment info. See: `Attachment`.
|
||||
/// @param[in] _destroyTextures If true, textures will be destroyed when
|
||||
/// frame buffer is destroyed.
|
||||
///
|
||||
/// @attention C99 equivalent is `bgfx_create_frame_buffer_from_handles`.
|
||||
///
|
||||
FrameBufferHandle createFrameBuffer(uint8_t _num, const TextureHandle* _handles, const uint8_t* _side, bool _destroyTextures = false);
|
||||
FrameBufferHandle createFrameBuffer(uint8_t _num, const Attachment* _attachment, bool _destroyTextures = false);
|
||||
|
||||
/// Create frame buffer for multiple window rendering.
|
||||
///
|
||||
|
@ -6,7 +6,7 @@
|
||||
#ifndef BGFX_DEFINES_H_HEADER_GUARD
|
||||
#define BGFX_DEFINES_H_HEADER_GUARD
|
||||
|
||||
#define BGFX_API_VERSION UINT32_C(8)
|
||||
#define BGFX_API_VERSION UINT32_C(9)
|
||||
|
||||
///
|
||||
#define BGFX_STATE_RGB_WRITE UINT64_C(0x0000000000000001) //!< Enable RGB write.
|
||||
|
@ -349,6 +349,15 @@ typedef struct bgfx_texture_info
|
||||
|
||||
} bgfx_texture_info_t;
|
||||
|
||||
/**/
|
||||
typedef struct bgfx_attachment
|
||||
{
|
||||
bgfx_texture_handle_t handle;
|
||||
uint16_t mip;
|
||||
uint16_t layer;
|
||||
|
||||
} bgfx_attachment_t;
|
||||
|
||||
/**/
|
||||
typedef struct bgfx_caps_gpu
|
||||
{
|
||||
@ -639,7 +648,7 @@ BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer(uint16_t _width,
|
||||
BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_scaled(bgfx_backbuffer_ratio_t _ratio, bgfx_texture_format_t _format, uint32_t _textureFlags);
|
||||
|
||||
/**/
|
||||
BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_handles(uint8_t _num, const bgfx_texture_handle_t* _handles, const uint8_t* _side, 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);
|
||||
|
||||
/**/
|
||||
BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_nwh(void* _nwh, uint16_t _width, uint16_t _height, bgfx_texture_format_t _depthFormat);
|
||||
|
@ -137,7 +137,7 @@ typedef struct bgfx_interface_vtbl
|
||||
void (*destroy_texture)(bgfx_texture_handle_t _handle);
|
||||
bgfx_frame_buffer_handle_t (*create_frame_buffer)(uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, uint32_t _textureFlags);
|
||||
bgfx_frame_buffer_handle_t (*create_frame_buffer_scaled)(bgfx_backbuffer_ratio_t _ratio, bgfx_texture_format_t _format, uint32_t _textureFlags);
|
||||
bgfx_frame_buffer_handle_t (*create_frame_buffer_from_handles)(uint8_t _num, const bgfx_texture_handle_t* _handles, const uint8_t* _side, bool _destroyTextures);
|
||||
bgfx_frame_buffer_handle_t (*create_frame_buffer_from_attachment)(uint8_t _num, const bgfx_attachment_t* _attachment, bool _destroyTextures);
|
||||
bgfx_frame_buffer_handle_t (*create_frame_buffer_from_nwh)(void* _nwh, uint16_t _width, uint16_t _height, bgfx_texture_format_t _depthFormat);
|
||||
void (*destroy_frame_buffer)(bgfx_frame_buffer_handle_t _handle);
|
||||
bgfx_uniform_handle_t (*create_uniform)(const char* _name, bgfx_uniform_type_t _type, uint16_t _num);
|
||||
|
35
src/bgfx.cpp
35
src/bgfx.cpp
@ -2259,15 +2259,10 @@ again:
|
||||
uint8_t num;
|
||||
_cmdbuf.read(num);
|
||||
|
||||
TextureHandle textureHandles[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
|
||||
uint8_t side[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
|
||||
for (uint32_t ii = 0; ii < num; ++ii)
|
||||
{
|
||||
_cmdbuf.read(textureHandles[ii]);
|
||||
_cmdbuf.read(side[ii]);
|
||||
}
|
||||
Attachment attachment[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
|
||||
_cmdbuf.read(attachment, sizeof(Attachment) * num);
|
||||
|
||||
m_renderCtx->createFrameBuffer(handle, num, textureHandles, side);
|
||||
m_renderCtx->createFrameBuffer(handle, num, attachment);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -3114,11 +3109,18 @@ again:
|
||||
|
||||
FrameBufferHandle createFrameBuffer(uint8_t _num, const TextureHandle* _handles, bool _destroyTextures)
|
||||
{
|
||||
uint8_t side[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS] = {};
|
||||
return createFrameBuffer(_num, _handles, side, _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 TextureHandle* _handles, const uint8_t* _side, bool _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.");
|
||||
@ -3126,9 +3128,8 @@ again:
|
||||
, _num
|
||||
, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS
|
||||
);
|
||||
BX_CHECK(NULL != _handles, "_handles can't be NULL");
|
||||
BX_CHECK(NULL != _side, "_side can't be NULL");
|
||||
return s_ctx->createFrameBuffer(_num, _handles, _side, _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)
|
||||
@ -4123,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, const uint8_t* _side, 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, _side, _destroyTextures);
|
||||
handle.cpp = bgfx::createFrameBuffer(_num, (const bgfx::Attachment*)_attachment, _destroyTextures);
|
||||
return handle.c;
|
||||
}
|
||||
|
||||
@ -4569,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) \
|
||||
|
21
src/bgfx_p.h
21
src/bgfx_p.h
@ -2052,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, const uint8_t* _side) = 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;
|
||||
@ -3184,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;
|
||||
@ -3207,9 +3207,9 @@ namespace bgfx
|
||||
;
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(FrameBufferHandle createFrameBuffer(uint8_t _num, const TextureHandle* _handles, const uint8_t* _side, 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
|
||||
@ -3228,27 +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);
|
||||
cmdbuf.write(_side[ii]);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1778,9 +1778,9 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
m_textures[_handle.idx].destroy();
|
||||
}
|
||||
|
||||
void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const TextureHandle* _textureHandles, const uint8_t* _side) BX_OVERRIDE
|
||||
void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const Attachment* _attachment) BX_OVERRIDE
|
||||
{
|
||||
m_frameBuffers[_handle.idx].create(_num, _textureHandles, _side);
|
||||
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, const uint8_t* _side)
|
||||
void FrameBufferD3D11::create(uint8_t _num, const Attachment* _attachment)
|
||||
{
|
||||
for (uint32_t ii = 0; ii < BX_COUNTOF(m_rtv); ++ii)
|
||||
{
|
||||
@ -4262,8 +4262,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
m_swapChain = NULL;
|
||||
|
||||
m_numTh = _num;
|
||||
memcpy(m_th, _handles, _num*sizeof(TextureHandle) );
|
||||
memcpy(m_side, _side, _num);
|
||||
memcpy(m_attachment, _attachment, _num*sizeof(Attachment) );
|
||||
|
||||
postReset();
|
||||
}
|
||||
@ -4356,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];
|
||||
@ -4405,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;
|
||||
@ -4418,14 +4417,14 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
{
|
||||
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY;
|
||||
dsvDesc.Texture2DMSArray.ArraySize = 1;
|
||||
dsvDesc.Texture2DMSArray.FirstArraySlice = m_side[ii];
|
||||
dsvDesc.Texture2DMSArray.FirstArraySlice = m_attachment[ii].layer;
|
||||
}
|
||||
else
|
||||
{
|
||||
dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
|
||||
dsvDesc.Texture2DArray.ArraySize = 1;
|
||||
dsvDesc.Texture2DArray.FirstArraySlice = m_side[ii];
|
||||
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) );
|
||||
@ -4439,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:
|
||||
@ -4450,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 = m_side[ii];
|
||||
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]) );
|
||||
}
|
||||
@ -4468,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;
|
||||
|
@ -261,7 +261,7 @@ namespace bgfx { namespace d3d11
|
||||
{
|
||||
}
|
||||
|
||||
void create(uint8_t _num, const TextureHandle* _handles, const uint8_t* _side);
|
||||
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,8 +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];
|
||||
uint8_t m_side[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
|
||||
Attachment m_attachment[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
|
||||
};
|
||||
|
||||
struct TimerQueryD3D11
|
||||
|
@ -1388,9 +1388,9 @@ namespace bgfx { namespace d3d12
|
||||
m_textures[_handle.idx].destroy();
|
||||
}
|
||||
|
||||
void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const TextureHandle* _textureHandles, const uint8_t* _side) BX_OVERRIDE
|
||||
void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const Attachment* _attachment) BX_OVERRIDE
|
||||
{
|
||||
m_frameBuffers[_handle.idx].create(_num, _textureHandles, _side);
|
||||
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,11 +4184,10 @@ data.NumQualityLevels = 0;
|
||||
return _state;
|
||||
}
|
||||
|
||||
void FrameBufferD3D12::create(uint8_t _num, const TextureHandle* _handles, const uint8_t* _side)
|
||||
void FrameBufferD3D12::create(uint8_t _num, const Attachment* _attachment)
|
||||
{
|
||||
m_numTh = _num;
|
||||
memcpy(m_th, _handles, _num*sizeof(TextureHandle) );
|
||||
memcpy(m_side, _side, _num);
|
||||
memcpy(m_attachment, _attachment, _num*sizeof(Attachment) );
|
||||
|
||||
postReset();
|
||||
}
|
||||
@ -4218,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];
|
||||
|
@ -295,7 +295,7 @@ namespace bgfx { namespace d3d12
|
||||
m_depth.idx = bgfx::invalidHandle;
|
||||
}
|
||||
|
||||
void create(uint8_t _num, const TextureHandle* _handles, const uint8_t* _side);
|
||||
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,8 +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];
|
||||
uint8_t m_side[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
|
||||
Attachment m_attachment[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
|
||||
};
|
||||
|
||||
struct CommandQueueD3D12
|
||||
|
@ -1018,9 +1018,9 @@ namespace bgfx { namespace d3d9
|
||||
m_textures[_handle.idx].destroy();
|
||||
}
|
||||
|
||||
void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const TextureHandle* _textureHandles, const uint8_t* _side) BX_OVERRIDE
|
||||
void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const Attachment* _attachment) BX_OVERRIDE
|
||||
{
|
||||
m_frameBuffers[_handle.idx].create(_num, _textureHandles, _side);
|
||||
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, const uint8_t* _side)
|
||||
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(_side[ii]);
|
||||
m_color[m_num] = texture.getSurface(uint8_t(_attachment[ii].layer) );
|
||||
}
|
||||
m_num++;
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ namespace bgfx { namespace d3d9
|
||||
m_depthHandle.idx = invalidHandle;
|
||||
}
|
||||
|
||||
void create(uint8_t _num, const TextureHandle* _handles, const uint8_t* _side);
|
||||
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();
|
||||
|
@ -2243,9 +2243,9 @@ namespace bgfx { namespace gl
|
||||
m_textures[_handle.idx].destroy();
|
||||
}
|
||||
|
||||
void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const TextureHandle* _textureHandles, const uint8_t* _side) BX_OVERRIDE
|
||||
void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const Attachment* _attachment) BX_OVERRIDE
|
||||
{
|
||||
m_frameBuffers[_handle.idx].create(_num, _textureHandles, _side);
|
||||
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,13 +5017,12 @@ namespace bgfx { namespace gl
|
||||
BX_UNUSED(complete);
|
||||
}
|
||||
|
||||
void FrameBufferGL::create(uint8_t _num, const TextureHandle* _handles, const uint8_t* _side)
|
||||
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_side, _side, _num);
|
||||
memcpy(m_attachment, _attachment, _num*sizeof(Attachment) );
|
||||
|
||||
postReset();
|
||||
}
|
||||
@ -5041,7 +5040,7 @@ 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];
|
||||
@ -5087,7 +5086,7 @@ namespace bgfx { namespace gl
|
||||
else
|
||||
{
|
||||
GLenum target = GL_TEXTURE_CUBE_MAP == texture.m_target
|
||||
? GL_TEXTURE_CUBE_MAP_POSITIVE_X + m_side[ii]
|
||||
? GL_TEXTURE_CUBE_MAP_POSITIVE_X + m_attachment[ii].layer
|
||||
: texture.m_target
|
||||
;
|
||||
|
||||
@ -5095,7 +5094,7 @@ namespace bgfx { namespace gl
|
||||
, attachment
|
||||
, target
|
||||
, texture.m_id
|
||||
, 0
|
||||
, m_attachment[ii].mip
|
||||
) );
|
||||
}
|
||||
|
||||
@ -5135,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];
|
||||
@ -5146,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
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
@ -1170,7 +1170,7 @@ namespace bgfx { namespace gl
|
||||
memset(m_fbo, 0, sizeof(m_fbo) );
|
||||
}
|
||||
|
||||
void create(uint8_t _num, const TextureHandle* _handles, const uint8_t* _side);
|
||||
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();
|
||||
@ -1184,8 +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];
|
||||
uint8_t m_side[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
|
||||
Attachment m_attachment[BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS];
|
||||
};
|
||||
|
||||
struct ProgramGL
|
||||
|
@ -694,7 +694,7 @@ namespace bgfx { namespace mtl
|
||||
m_depthHandle.idx = invalidHandle;
|
||||
}
|
||||
|
||||
void create(uint8_t _num, const TextureHandle* _handles, const uint8_t* _side);
|
||||
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();
|
||||
|
@ -694,9 +694,9 @@ namespace bgfx { namespace mtl
|
||||
m_textures[_handle.idx].destroy();
|
||||
}
|
||||
|
||||
void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const TextureHandle* _textureHandles, const uint8_t* _side) BX_OVERRIDE
|
||||
void createFrameBuffer(FrameBufferHandle _handle, uint8_t _num, const Attachment* _attachment) BX_OVERRIDE
|
||||
{
|
||||
m_frameBuffers[_handle.idx].create(_num, _textureHandles, _side);
|
||||
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, const uint8_t* /*_side*/)
|
||||
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];
|
||||
|
@ -134,7 +134,7 @@ namespace bgfx { namespace noop
|
||||
{
|
||||
}
|
||||
|
||||
void createFrameBuffer(FrameBufferHandle /*_handle*/, uint8_t /*_num*/, const TextureHandle* /*_textureHandles*/, const uint8_t* /*_side*/) BX_OVERRIDE
|
||||
void createFrameBuffer(FrameBufferHandle /*_handle*/, uint8_t /*_num*/, const Attachment* /*_attachment*/) BX_OVERRIDE
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user