mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-24 16:48:18 -05:00
Added BGFX_RESET_DEPTH_CLAMP. Issue #598.
This commit is contained in:
parent
a70686aa48
commit
06e1486132
4 changed files with 49 additions and 13 deletions
|
@ -354,6 +354,7 @@
|
|||
#define BGFX_RESET_FLIP_AFTER_RENDER UINT32_C(0x00004000) //!< This flag specifies where flip occurs. Default behavior is that flip occurs before rendering new frame. This flag only has effect when `BGFX_CONFIG_MULTITHREADED=0`.
|
||||
#define BGFX_RESET_SRGB_BACKBUFFER UINT32_C(0x00008000) //!< Enable sRGB backbuffer.
|
||||
#define BGFX_RESET_HIDPI UINT32_C(0x00010000) //!< Enable HiDPI rendering.
|
||||
#define BGFX_RESET_DEPTH_CLAMP UINT32_C(0x00020000) //!< Enable depth clamp.
|
||||
|
||||
#define BGFX_RESET_RESERVED_SHIFT 31 //!< Internal bits shift.
|
||||
#define BGFX_RESET_RESERVED_MASK UINT32_C(0x80000000) //!< Internal bits mask.
|
||||
|
|
|
@ -586,6 +586,7 @@ namespace bgfx { namespace d3d11
|
|||
, m_captureResolve(NULL)
|
||||
, m_wireframe(false)
|
||||
, m_maxAnisotropy(1)
|
||||
, m_depthClamp(false)
|
||||
, m_currentProgram(NULL)
|
||||
, m_vsChanges(0)
|
||||
, m_fsChanges(0)
|
||||
|
@ -2166,19 +2167,34 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
|||
{
|
||||
bool recenter = !!(_resolution.m_flags & BGFX_RESET_HMD_RECENTER);
|
||||
|
||||
uint32_t maxAnisotropy = 1;
|
||||
if (!!(_resolution.m_flags & BGFX_RESET_MAXANISOTROPY) )
|
||||
{
|
||||
m_maxAnisotropy = (m_featureLevel == D3D_FEATURE_LEVEL_9_1)
|
||||
maxAnisotropy = (m_featureLevel == D3D_FEATURE_LEVEL_9_1)
|
||||
? D3D_FL9_1_DEFAULT_MAX_ANISOTROPY
|
||||
: D3D11_REQ_MAXANISOTROPY
|
||||
;
|
||||
}
|
||||
else
|
||||
|
||||
if (m_maxAnisotropy != maxAnisotropy)
|
||||
{
|
||||
m_maxAnisotropy = 1;
|
||||
m_maxAnisotropy = maxAnisotropy;
|
||||
m_samplerStateCache.invalidate();
|
||||
}
|
||||
|
||||
uint32_t flags = _resolution.m_flags & ~(BGFX_RESET_HMD_RECENTER | BGFX_RESET_MAXANISOTROPY);
|
||||
bool depthClamp = false;
|
||||
if (!!(_resolution.m_flags & BGFX_RESET_DEPTH_CLAMP) )
|
||||
{
|
||||
depthClamp = m_featureLevel <= D3D_FEATURE_LEVEL_9_3; // disabling depth clamp is only supported on 10_0+
|
||||
}
|
||||
|
||||
if (m_depthClamp != depthClamp)
|
||||
{
|
||||
m_depthClamp = depthClamp;
|
||||
m_rasterizerStateCache.invalidate();
|
||||
}
|
||||
|
||||
uint32_t flags = _resolution.m_flags & ~(BGFX_RESET_HMD_RECENTER | BGFX_RESET_MAXANISOTROPY | BGFX_RESET_DEPTH_CLAMP);
|
||||
|
||||
if (m_resolution.m_width != _resolution.m_width
|
||||
|| m_resolution.m_height != _resolution.m_height
|
||||
|
@ -2657,7 +2673,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
|||
desc.DepthBias = 0;
|
||||
desc.DepthBiasClamp = 0.0f;
|
||||
desc.SlopeScaledDepthBias = 0.0f;
|
||||
desc.DepthClipEnable = m_featureLevel <= D3D_FEATURE_LEVEL_9_3; // disabling depth clip is only supported on 10_0+
|
||||
desc.DepthClipEnable = m_depthClamp;
|
||||
desc.ScissorEnable = _scissor;
|
||||
desc.MultisampleEnable = !!(_state&BGFX_STATE_MSAA);
|
||||
desc.AntialiasedLineEnable = false;
|
||||
|
@ -3340,6 +3356,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
|||
|
||||
SwapChainDesc m_scd;
|
||||
uint32_t m_maxAnisotropy;
|
||||
bool m_depthClamp;
|
||||
|
||||
IndexBufferD3D11 m_indexBuffers[BGFX_CONFIG_MAX_INDEX_BUFFERS];
|
||||
VertexBufferD3D11 m_vertexBuffers[BGFX_CONFIG_MAX_VERTEX_BUFFERS];
|
||||
|
|
|
@ -459,6 +459,7 @@ namespace bgfx { namespace d3d12
|
|||
RendererContextD3D12()
|
||||
: m_wireframe(false)
|
||||
, m_maxAnisotropy(1)
|
||||
, m_depthClamp(false)
|
||||
, m_fsChanges(0)
|
||||
, m_vsChanges(0)
|
||||
, m_backBufferColorIdx(0)
|
||||
|
@ -1729,7 +1730,15 @@ data.NumQualityLevels = 0;
|
|||
m_maxAnisotropy = 1;
|
||||
}
|
||||
|
||||
uint32_t flags = _resolution.m_flags & ~(BGFX_RESET_HMD_RECENTER | BGFX_RESET_MAXANISOTROPY);
|
||||
bool depthClamp = !!(_resolution.m_flags & BGFX_RESET_DEPTH_CLAMP);
|
||||
|
||||
if (m_depthClamp != depthClamp)
|
||||
{
|
||||
m_depthClamp = depthClamp;
|
||||
m_pipelineStateCache.invalidate();
|
||||
}
|
||||
|
||||
uint32_t flags = _resolution.m_flags & ~(BGFX_RESET_HMD_RECENTER | BGFX_RESET_MAXANISOTROPY | BGFX_RESET_DEPTH_CLAMP);
|
||||
|
||||
if (m_resolution.m_width != _resolution.m_width
|
||||
|| m_resolution.m_height != _resolution.m_height
|
||||
|
@ -2007,7 +2016,7 @@ data.NumQualityLevels = 0;
|
|||
desc.DepthBias = 0;
|
||||
desc.DepthBiasClamp = 0.0f;
|
||||
desc.SlopeScaledDepthBias = 0.0f;
|
||||
desc.DepthClipEnable = false;
|
||||
desc.DepthClipEnable = m_depthClamp;
|
||||
desc.MultisampleEnable = !!(_state&BGFX_STATE_MSAA);
|
||||
desc.AntialiasedLineEnable = false;
|
||||
desc.ForcedSampleCount = 0;
|
||||
|
@ -2636,6 +2645,7 @@ data.NumQualityLevels = 0;
|
|||
|
||||
DXGI_SWAP_CHAIN_DESC m_scd;
|
||||
uint32_t m_maxAnisotropy;
|
||||
bool m_depthClamp;
|
||||
|
||||
BufferD3D12 m_indexBuffers[BGFX_CONFIG_MAX_INDEX_BUFFERS];
|
||||
VertexBufferD3D12 m_vertexBuffers[BGFX_CONFIG_MAX_VERTEX_BUFFERS];
|
||||
|
|
|
@ -1936,11 +1936,6 @@ namespace bgfx { namespace gl
|
|||
GL_CHECK(glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS) );
|
||||
}
|
||||
|
||||
if (s_extension[Extension::ARB_depth_clamp].m_supported)
|
||||
{
|
||||
GL_CHECK(glEnable(GL_DEPTH_CLAMP) );
|
||||
}
|
||||
|
||||
if (NULL == glFrameTerminatorGREMEDY
|
||||
|| !s_extension[Extension::GREMEDY_frame_terminator].m_supported)
|
||||
{
|
||||
|
@ -2404,7 +2399,20 @@ namespace bgfx { namespace gl
|
|||
? m_maxAnisotropyDefault
|
||||
: 0.0f
|
||||
;
|
||||
uint32_t flags = _resolution.m_flags & ~(BGFX_RESET_HMD_RECENTER | BGFX_RESET_MAXANISOTROPY);
|
||||
|
||||
if (s_extension[Extension::ARB_depth_clamp].m_supported)
|
||||
{
|
||||
if (!!(_resolution.m_flags & BGFX_RESET_DEPTH_CLAMP) )
|
||||
{
|
||||
GL_CHECK(glEnable(GL_DEPTH_CLAMP) );
|
||||
}
|
||||
else
|
||||
{
|
||||
GL_CHECK(glDisable(GL_DEPTH_CLAMP) );
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t flags = _resolution.m_flags & ~(BGFX_RESET_HMD_RECENTER | BGFX_RESET_MAXANISOTROPY | BGFX_RESET_DEPTH_CLAMP);
|
||||
|
||||
if (m_resolution.m_width != _resolution.m_width
|
||||
|| m_resolution.m_height != _resolution.m_height
|
||||
|
|
Loading…
Reference in a new issue