mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-29 17:52:18 +01:00
[dxvk] Initial support for post-compute barriers
This commit is contained in:
parent
a51439fb29
commit
8691d29185
@ -969,7 +969,40 @@ namespace dxvk {
|
||||
|
||||
|
||||
void DxvkContext::commitComputeBarriers() {
|
||||
// TODO implement
|
||||
// TODO optimize. Each pipeline layout should
|
||||
// hold a list of resource that can be written.
|
||||
// TODO generalize so that this can be used for
|
||||
// graphics pipelines as well
|
||||
auto layout = m_state.cp.pipeline->layout();
|
||||
|
||||
for (uint32_t i = 0; i < layout->bindingCount(); i++) {
|
||||
const DxvkDescriptorSlot binding = layout->binding(i);
|
||||
const DxvkShaderResourceSlot& slot = m_rc[binding.slot];
|
||||
|
||||
if (binding.type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) {
|
||||
m_barriers.accessBuffer(
|
||||
slot.bufferSlice.buffer(),
|
||||
slot.bufferSlice.offset(),
|
||||
slot.bufferSlice.length(),
|
||||
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
VK_ACCESS_SHADER_READ_BIT |
|
||||
VK_ACCESS_SHADER_WRITE_BIT,
|
||||
slot.bufferSlice.buffer()->info().stages,
|
||||
slot.bufferSlice.buffer()->info().access);
|
||||
} else if (binding.type == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER) {
|
||||
m_barriers.accessBuffer(
|
||||
slot.bufferView->buffer(),
|
||||
slot.bufferView->info().rangeOffset,
|
||||
slot.bufferView->info().rangeLength,
|
||||
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
VK_ACCESS_SHADER_READ_BIT |
|
||||
VK_ACCESS_SHADER_WRITE_BIT,
|
||||
slot.bufferView->buffer()->info().stages,
|
||||
slot.bufferView->buffer()->info().access);
|
||||
}
|
||||
}
|
||||
|
||||
m_barriers.recordCommands(m_cmd);
|
||||
}
|
||||
|
||||
|
||||
|
@ -166,6 +166,6 @@ int WINAPI WinMain(HINSTANCE hInstance,
|
||||
std::memcpy(&result, mappedResource.pData, sizeof(result));
|
||||
context->Unmap(readBuffer.ptr(), 0);
|
||||
|
||||
std::cout << "Sum: " << result << std::endl;
|
||||
std::cout << "Sum of the numbers 1 to " << srcData.size() << " = " << result << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user