Merge branch 'master' of cane:bkaradzic/bgfx into dev

This commit is contained in:
Branimir Karadžić 2015-08-03 23:05:13 -07:00
commit 2c8137ec41
2 changed files with 38 additions and 18 deletions

View file

@ -1143,39 +1143,62 @@ namespace bgfx { namespace d3d12
m_cmd.finish(m_backBufferColorFence[idx]); m_cmd.finish(m_backBufferColorFence[idx]);
ID3D12Resource* backBuffer = m_backBufferColor[idx]; ID3D12Resource* backBuffer = m_backBufferColor[idx];
D3D12_RESOURCE_DESC backBufferDesc = backBuffer->GetDesc(); D3D12_RESOURCE_DESC desc = backBuffer->GetDesc();
const uint32_t width = (uint32_t)backBufferDesc.Width; const uint32_t width = (uint32_t)desc.Width;
const uint32_t height = (uint32_t)backBufferDesc.Height; const uint32_t height = (uint32_t)desc.Height;
const uint32_t pitch = bx::strideAlign(width * 4, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
const uint32_t slice = bx::strideAlign(height * pitch, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT); D3D12_PLACED_SUBRESOURCE_FOOTPRINT layout;
ID3D12Resource* staging = createCommittedResource(m_device, HeapProperty::ReadBack, slice); uint32_t numRows;
uint64_t total;
uint64_t pitch;
m_device->GetCopyableFootprints(&desc
, 0
, 1
, 0
, &layout
, &numRows
, &pitch
, &total
);
ID3D12Resource* readback = createCommittedResource(m_device, HeapProperty::ReadBack, total);
D3D12_BOX box;
box.left = 0;
box.top = 0;
box.right = width;
box.bottom = height;
box.front = 0;
box.back = 1;
setResourceBarrier(m_commandList, backBuffer, D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_COPY_SOURCE); setResourceBarrier(m_commandList, backBuffer, D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_COPY_SOURCE);
m_commandList->CopyResource(staging, backBuffer); D3D12_TEXTURE_COPY_LOCATION dst = { readback, D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, layout };
D3D12_TEXTURE_COPY_LOCATION src = { backBuffer, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, { 0 } };
m_commandList->CopyTextureRegion(&dst, 0, 0, 0, &src, &box);
setResourceBarrier(m_commandList, backBuffer, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_PRESENT); setResourceBarrier(m_commandList, backBuffer, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_PRESENT);
finish(); finish();
m_commandList = m_cmd.alloc(); m_commandList = m_cmd.alloc();
void* data; void* data;
staging->Map(0, NULL, (void**)&data); readback->Map(0, NULL, (void**)&data);
imageSwizzleBgra8(width imageSwizzleBgra8(width
, height , height
, pitch , (uint32_t)pitch
, data , data
, data , data
); );
g_callback->screenShot(_filePath g_callback->screenShot(_filePath
, width , width
, height , height
, pitch , (uint32_t)pitch
, data , data
, slice , (uint32_t)total
, false , false
); );
staging->Unmap(0, NULL); readback->Unmap(0, NULL);
DX_RELEASE(staging, 0); DX_RELEASE(readback, 0);
} }
void updateViewName(uint8_t /*_id*/, const char* /*_name*/) BX_OVERRIDE void updateViewName(uint8_t /*_id*/, const char* /*_name*/) BX_OVERRIDE
@ -1516,10 +1539,7 @@ data.NumQualityLevels = 0;
const bool bufferOnly = 0 != (texture.m_flags&BGFX_TEXTURE_RT_BUFFER_ONLY); const bool bufferOnly = 0 != (texture.m_flags&BGFX_TEXTURE_RT_BUFFER_ONLY);
if (!bufferOnly) if (!bufferOnly)
{ {
texture.setState(m_commandList, D3D12_RESOURCE_STATES(0) texture.setState(m_commandList, D3D12_RESOURCE_STATE_DEPTH_READ);
| D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE
// | D3D12_RESOURCE_STATE_DEPTH_READ
);
} }
} }
} }

View file

@ -341,7 +341,7 @@ namespace bgfx { namespace d3d12
void shutdown() void shutdown()
{ {
finish(); finish(UINT64_MAX, true);
DX_RELEASE(m_fence, 0); DX_RELEASE(m_fence, 0);