1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00

[dxvk] Use DxvkPhysicalBufferSlice for indirect draws and buffer binding

This commit is contained in:
Philip Rebohle 2018-01-18 18:01:47 +01:00
parent f41a7c7c87
commit 3212fc7444
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 34 additions and 26 deletions

View File

@ -222,6 +222,10 @@ namespace dxvk {
m_offset(rangeOffset), m_offset(rangeOffset),
m_length(rangeLength) { } m_length(rangeLength) { }
bool defined() const {
return m_buffer != nullptr;
}
Rc<DxvkBuffer> buffer() const { Rc<DxvkBuffer> buffer() const {
return m_buffer; return m_buffer;
} }
@ -258,14 +262,6 @@ namespace dxvk {
return m_buffer->mapPtr(m_offset + offset); return m_buffer->mapPtr(m_offset + offset);
} }
VkDescriptorBufferInfo descriptorInfo() const {
VkDescriptorBufferInfo info;
info.buffer = m_buffer->handle();
info.offset = m_offset;
info.range = m_length;
return info;
}
bool operator == (const DxvkBufferSlice& other) const { bool operator == (const DxvkBufferSlice& other) const {
return this->m_buffer == other.m_buffer return this->m_buffer == other.m_buffer
&& this->m_offset == other.m_offset && this->m_offset == other.m_offset

View File

@ -448,9 +448,11 @@ namespace dxvk {
const DxvkBufferSlice& buffer) { const DxvkBufferSlice& buffer) {
this->commitComputeState(); this->commitComputeState();
auto physicalSlice = buffer.physicalSlice();
m_cmd->cmdDispatchIndirect( m_cmd->cmdDispatchIndirect(
buffer.handle(), physicalSlice.handle(),
buffer.offset()); physicalSlice.offset());
this->commitComputeBarriers(); this->commitComputeBarriers();
} }
@ -478,9 +480,11 @@ namespace dxvk {
this->commitGraphicsState(); this->commitGraphicsState();
if (m_gpActivePipeline != VK_NULL_HANDLE) { if (m_gpActivePipeline != VK_NULL_HANDLE) {
auto physicalSlice = buffer.physicalSlice();
m_cmd->cmdDrawIndirect( m_cmd->cmdDrawIndirect(
buffer.handle(), physicalSlice.handle(),
buffer.offset(), physicalSlice.offset(),
count, stride); count, stride);
} }
} }
@ -510,9 +514,11 @@ namespace dxvk {
this->commitGraphicsState(); this->commitGraphicsState();
if (m_gpActivePipeline != VK_NULL_HANDLE) { if (m_gpActivePipeline != VK_NULL_HANDLE) {
auto physicalSlice = buffer.physicalSlice();
m_cmd->cmdDrawIndexedIndirect( m_cmd->cmdDrawIndexedIndirect(
buffer.handle(), physicalSlice.handle(),
buffer.offset(), physicalSlice.offset(),
count, stride); count, stride);
} }
} }
@ -1118,10 +1124,14 @@ namespace dxvk {
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
if (res.bufferSlice.handle() != VK_NULL_HANDLE) { if (res.bufferSlice.defined()) {
updatePipelineState |= bs.setBound(i); updatePipelineState |= bs.setBound(i);
m_descriptors[i].buffer = res.bufferSlice.descriptorInfo(); auto physicalSlice = res.bufferSlice.physicalSlice();
m_descriptors[i].buffer.buffer = physicalSlice.handle();
m_descriptors[i].buffer.offset = physicalSlice.offset();
m_descriptors[i].buffer.range = physicalSlice.length();
m_cmd->trackResource(res.bufferSlice.resource()); m_cmd->trackResource(res.bufferSlice.resource());
} else { } else {
updatePipelineState |= bs.setUnbound(i); updatePipelineState |= bs.setUnbound(i);
@ -1207,13 +1217,15 @@ namespace dxvk {
if (m_flags.test(DxvkContextFlag::GpDirtyIndexBuffer)) { if (m_flags.test(DxvkContextFlag::GpDirtyIndexBuffer)) {
m_flags.clr(DxvkContextFlag::GpDirtyIndexBuffer); m_flags.clr(DxvkContextFlag::GpDirtyIndexBuffer);
if (m_state.vi.indexBuffer.handle() != VK_NULL_HANDLE) { if (m_state.vi.indexBuffer.defined()) {
auto physicalSlice = m_state.vi.indexBuffer.physicalSlice();
m_cmd->cmdBindIndexBuffer( m_cmd->cmdBindIndexBuffer(
m_state.vi.indexBuffer.handle(), physicalSlice.handle(),
m_state.vi.indexBuffer.offset(), physicalSlice.offset(),
m_state.vi.indexType); m_state.vi.indexType);
m_cmd->trackResource( m_cmd->trackResource(
m_state.vi.indexBuffer.resource()); physicalSlice.resource());
} }
} }
} }
@ -1226,12 +1238,12 @@ namespace dxvk {
for (uint32_t i = 0; i < m_state.gp.state.ilBindingCount; i++) { for (uint32_t i = 0; i < m_state.gp.state.ilBindingCount; i++) {
const uint32_t binding = m_state.gp.state.ilBindings[i].binding; const uint32_t binding = m_state.gp.state.ilBindings[i].binding;
const DxvkBufferSlice& vbo = m_state.vi.vertexBuffers[binding]; if (m_state.vi.vertexBuffers[binding].defined()) {
auto vbo = m_state.vi.vertexBuffers[binding].physicalSlice();
const VkBuffer handle = vbo.handle();
const VkDeviceSize offset = vbo.offset(); const VkBuffer handle = vbo.handle();
const VkDeviceSize offset = vbo.offset();
if (handle != VK_NULL_HANDLE) {
m_cmd->cmdBindVertexBuffers(binding, 1, &handle, &offset); m_cmd->cmdBindVertexBuffers(binding, 1, &handle, &offset);
m_cmd->trackResource(vbo.resource()); m_cmd->trackResource(vbo.resource());
} }