mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 00:58:30 -05:00
Cleanup.
This commit is contained in:
parent
0184074392
commit
dd0cd19725
2 changed files with 13 additions and 32 deletions
|
@ -2389,7 +2389,6 @@ data.NumQualityLevels = 0;
|
||||||
|
|
||||||
bool isVisible(Frame* _render, OcclusionQueryHandle _handle, bool _visible)
|
bool isVisible(Frame* _render, OcclusionQueryHandle _handle, bool _visible)
|
||||||
{
|
{
|
||||||
m_occlusionQuery.resolve(_render);
|
|
||||||
return _visible == (0 != _render->m_occlusion[_handle.idx]);
|
return _visible == (0 != _render->m_occlusion[_handle.idx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4333,7 +4332,7 @@ data.NumQualityLevels = 0;
|
||||||
void OcclusionQueryD3D12::init()
|
void OcclusionQueryD3D12::init()
|
||||||
{
|
{
|
||||||
D3D12_QUERY_HEAP_DESC queryHeapDesc;
|
D3D12_QUERY_HEAP_DESC queryHeapDesc;
|
||||||
queryHeapDesc.Count = BX_COUNTOF(m_query);
|
queryHeapDesc.Count = BX_COUNTOF(m_handle);
|
||||||
queryHeapDesc.NodeMask = 1;
|
queryHeapDesc.NodeMask = 1;
|
||||||
queryHeapDesc.Type = D3D12_QUERY_HEAP_TYPE_OCCLUSION;
|
queryHeapDesc.Type = D3D12_QUERY_HEAP_TYPE_OCCLUSION;
|
||||||
DX_CHECK(s_renderD3D12->m_device->CreateQueryHeap(&queryHeapDesc
|
DX_CHECK(s_renderD3D12->m_device->CreateQueryHeap(&queryHeapDesc
|
||||||
|
@ -4343,10 +4342,10 @@ data.NumQualityLevels = 0;
|
||||||
|
|
||||||
m_readback = createCommittedResource(s_renderD3D12->m_device
|
m_readback = createCommittedResource(s_renderD3D12->m_device
|
||||||
, HeapProperty::ReadBack
|
, HeapProperty::ReadBack
|
||||||
, BX_COUNTOF(m_query)*sizeof(uint64_t)
|
, BX_COUNTOF(m_handle)*sizeof(uint64_t)
|
||||||
);
|
);
|
||||||
|
|
||||||
D3D12_RANGE range = { 0, BX_COUNTOF(m_query) };
|
D3D12_RANGE range = { 0, BX_COUNTOF(m_handle) };
|
||||||
m_readback->Map(0, &range, (void**)&m_result);
|
m_readback->Map(0, &range, (void**)&m_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4363,11 +4362,12 @@ data.NumQualityLevels = 0;
|
||||||
{
|
{
|
||||||
while (0 == m_control.reserve(1) )
|
while (0 == m_control.reserve(1) )
|
||||||
{
|
{
|
||||||
resolve(_render);
|
OcclusionQueryHandle handle = m_handle[m_control.m_read];
|
||||||
|
_render->m_occlusion[handle.idx] = 0 < m_result[handle.idx];
|
||||||
|
m_control.consume(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Query& query = m_query[m_control.m_current];
|
m_handle[m_control.m_current] = _handle;
|
||||||
query.m_handle = _handle;
|
|
||||||
_commandList->BeginQuery(m_queryHeap
|
_commandList->BeginQuery(m_queryHeap
|
||||||
, D3D12_QUERY_TYPE_BINARY_OCCLUSION
|
, D3D12_QUERY_TYPE_BINARY_OCCLUSION
|
||||||
, _handle.idx
|
, _handle.idx
|
||||||
|
@ -4376,32 +4376,21 @@ data.NumQualityLevels = 0;
|
||||||
|
|
||||||
void OcclusionQueryD3D12::end(ID3D12GraphicsCommandList* _commandList)
|
void OcclusionQueryD3D12::end(ID3D12GraphicsCommandList* _commandList)
|
||||||
{
|
{
|
||||||
Query& query = m_query[m_control.m_current];
|
OcclusionQueryHandle handle = m_handle[m_control.m_current];
|
||||||
_commandList->EndQuery(m_queryHeap
|
_commandList->EndQuery(m_queryHeap
|
||||||
, D3D12_QUERY_TYPE_BINARY_OCCLUSION
|
, D3D12_QUERY_TYPE_BINARY_OCCLUSION
|
||||||
, query.m_handle.idx
|
, handle.idx
|
||||||
);
|
);
|
||||||
_commandList->ResolveQueryData(m_queryHeap
|
_commandList->ResolveQueryData(m_queryHeap
|
||||||
, D3D12_QUERY_TYPE_BINARY_OCCLUSION
|
, D3D12_QUERY_TYPE_BINARY_OCCLUSION
|
||||||
, query.m_handle.idx
|
, handle.idx
|
||||||
, 1
|
, 1
|
||||||
, m_readback
|
, m_readback
|
||||||
, query.m_handle.idx * sizeof(uint64_t)
|
, handle.idx * sizeof(uint64_t)
|
||||||
);
|
);
|
||||||
m_control.commit(1);
|
m_control.commit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OcclusionQueryD3D12::resolve(Frame* _render)
|
|
||||||
{
|
|
||||||
while (0 != m_control.available() )
|
|
||||||
{
|
|
||||||
Query& query = m_query[m_control.m_read];
|
|
||||||
|
|
||||||
_render->m_occlusion[query.m_handle.idx] = 0 < m_result[query.m_handle.idx];
|
|
||||||
m_control.consume(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Bind
|
struct Bind
|
||||||
{
|
{
|
||||||
D3D12_GPU_DESCRIPTOR_HANDLE m_srvHandle;
|
D3D12_GPU_DESCRIPTOR_HANDLE m_srvHandle;
|
||||||
|
@ -4497,8 +4486,6 @@ data.NumQualityLevels = 0;
|
||||||
, D3D12_RESOURCE_STATE_RENDER_TARGET
|
, D3D12_RESOURCE_STATE_RENDER_TARGET
|
||||||
);
|
);
|
||||||
|
|
||||||
m_occlusionQuery.resolve(_render);
|
|
||||||
|
|
||||||
if (0 == (_render->m_debug&BGFX_DEBUG_IFH) )
|
if (0 == (_render->m_debug&BGFX_DEBUG_IFH) )
|
||||||
{
|
{
|
||||||
m_batch.begin();
|
m_batch.begin();
|
||||||
|
|
|
@ -435,7 +435,7 @@ namespace bgfx { namespace d3d12
|
||||||
struct OcclusionQueryD3D12
|
struct OcclusionQueryD3D12
|
||||||
{
|
{
|
||||||
OcclusionQueryD3D12()
|
OcclusionQueryD3D12()
|
||||||
: m_control(BX_COUNTOF(m_query) )
|
: m_control(BX_COUNTOF(m_handle) )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,16 +443,10 @@ namespace bgfx { namespace d3d12
|
||||||
void shutdown();
|
void shutdown();
|
||||||
void begin(ID3D12GraphicsCommandList* _commandList, Frame* _render, OcclusionQueryHandle _handle);
|
void begin(ID3D12GraphicsCommandList* _commandList, Frame* _render, OcclusionQueryHandle _handle);
|
||||||
void end(ID3D12GraphicsCommandList* _commandList);
|
void end(ID3D12GraphicsCommandList* _commandList);
|
||||||
void resolve(Frame* _render);
|
|
||||||
|
|
||||||
struct Query
|
|
||||||
{
|
|
||||||
OcclusionQueryHandle m_handle;
|
|
||||||
};
|
|
||||||
|
|
||||||
ID3D12Resource* m_readback;
|
ID3D12Resource* m_readback;
|
||||||
ID3D12QueryHeap* m_queryHeap;
|
ID3D12QueryHeap* m_queryHeap;
|
||||||
Query m_query[BGFX_CONFIG_MAX_OCCUSION_QUERIES];
|
OcclusionQueryHandle m_handle[BGFX_CONFIG_MAX_OCCUSION_QUERIES];
|
||||||
uint64_t* m_result;
|
uint64_t* m_result;
|
||||||
bx::RingBufferControl m_control;
|
bx::RingBufferControl m_control;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue