Skip to content

Commit

Permalink
D3D11: Made use staging buffer configurable.
Browse files Browse the repository at this point in the history
  • Loading branch information
bkaradzic committed Mar 28, 2024
1 parent dc2bb19 commit 8ec4b71
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@
# define BGFX_CONFIG_RENDERER_USE_EXTENSIONS 1
#endif // BGFX_CONFIG_RENDERER_USE_EXTENSIONS

#ifndef BGFX_CONFIG_RENDERER_DIRECT3D11_USE_STAGING_BUFFER
# define BGFX_CONFIG_RENDERER_DIRECT3D11_USE_STAGING_BUFFER 0
#endif // BGFX_CONFIG_RENDERER_DIRECT3D11_USE_STAGING_BUFFER

/// Enable use of tinystl.
#ifndef BGFX_CONFIG_USE_TINYSTL
# define BGFX_CONFIG_USE_TINYSTL 1
Expand Down
6 changes: 3 additions & 3 deletions src/renderer_d3d11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3830,7 +3830,7 @@ namespace bgfx { namespace d3d11
}
else if (m_dynamic)
{
#if USE_D3D11_STAGING_BUFFER
#if BGFX_CONFIG_RENDERER_DIRECT3D11_USE_STAGING_BUFFER
desc.Usage = D3D11_USAGE_DEFAULT;
desc.CPUAccessFlags = 0;

Expand All @@ -3855,7 +3855,7 @@ namespace bgfx { namespace d3d11
, NULL
, &m_ptr
) );
#endif // USE_D3D11_STAGING_BUFFER
#endif // BGFX_CONFIG_RENDERER_DIRECT3D11_USE_STAGING_BUFFER
}
else
{
Expand Down Expand Up @@ -3887,7 +3887,7 @@ namespace bgfx { namespace d3d11
ID3D11DeviceContext* deviceCtx = s_renderD3D11->m_deviceCtx;
BX_ASSERT(m_dynamic, "Must be dynamic!");

#if USE_D3D11_STAGING_BUFFER
#if BGFX_CONFIG_RENDERER_DIRECT3D11_USE_STAGING_BUFFER
BX_UNUSED(_discard);

D3D11_MAPPED_SUBRESOURCE mapped;
Expand Down
13 changes: 6 additions & 7 deletions src/renderer_d3d11.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#define BGFX_RENDERER_D3D11_H_HEADER_GUARD

#define USE_D3D11_DYNAMIC_LIB (BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS)
#define USE_D3D11_STAGING_BUFFER 0

#if !USE_D3D11_DYNAMIC_LIB
# undef BGFX_CONFIG_DEBUG_ANNOTATION
Expand Down Expand Up @@ -81,9 +80,9 @@ namespace bgfx { namespace d3d11
{
BufferD3D11()
: m_ptr(NULL)
#if USE_D3D11_STAGING_BUFFER
#if BGFX_CONFIG_RENDERER_DIRECT3D11_USE_STAGING_BUFFER
, m_staging(NULL)
#endif // USE_D3D11_STAGING_BUFFER
#endif // BGFX_CONFIG_RENDERER_DIRECT3D11_USE_STAGING_BUFFER
, m_srv(NULL)
, m_uav(NULL)
, m_flags(BGFX_BUFFER_NONE)
Expand All @@ -102,18 +101,18 @@ namespace bgfx { namespace d3d11
m_dynamic = false;
}

#if USE_D3D11_STAGING_BUFFER
#if BGFX_CONFIG_RENDERER_DIRECT3D11_USE_STAGING_BUFFER
DX_RELEASE(m_staging, 0);
#endif // USE_D3D11_STAGING_BUFFER
#endif // BGFX_CONFIG_RENDERER_DIRECT3D11_USE_STAGING_BUFFER

DX_RELEASE(m_srv, 0);
DX_RELEASE(m_uav, 0);
}

ID3D11Buffer* m_ptr;
#if USE_D3D11_STAGING_BUFFER
#if BGFX_CONFIG_RENDERER_DIRECT3D11_USE_STAGING_BUFFER
ID3D11Buffer* m_staging;
#endif // USE_D3D11_STAGING_BUFFER
#endif // BGFX_CONFIG_RENDERER_DIRECT3D11_USE_STAGING_BUFFER
ID3D11ShaderResourceView* m_srv;
ID3D11UnorderedAccessView* m_uav;
uint32_t m_size;
Expand Down

0 comments on commit 8ec4b71

Please sign in to comment.