1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-02 01:24:11 +01:00

[dxvk] Rename DxvkBindingState -> DxvkBindingMask

Preparation for some more binding-related work.
This commit is contained in:
Philip Rebohle 2018-09-17 10:40:57 +02:00
parent eac86fab15
commit f42f708f72
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
8 changed files with 28 additions and 33 deletions

View File

@ -9,14 +9,14 @@
namespace dxvk {
/**
* \brief Binding state
* \brief Binding mask
*
* Used to track which resource slots have a compatible
* binding and which ones don't. This is used to set up
* binding-related specialization constants in shaders.
* \tparam N Number of binding slots
*/
class DxvkBindingState {
class DxvkBindingMask {
constexpr static uint32_t BitCount = 32;
constexpr static uint32_t IntCount = (MaxNumActiveBindings + BitCount - 1) / BitCount;
public:

View File

@ -2,7 +2,7 @@
#include <limits>
#include "dxvk_binding.h"
#include "dxvk_bind_mask.h"
#include "dxvk_buffer.h"
#include "dxvk_descriptor.h"
#include "dxvk_event_tracker.h"

View File

@ -107,7 +107,7 @@ namespace dxvk {
DxvkSpecConstantData specData;
for (uint32_t i = 0; i < MaxNumActiveBindings; i++)
specData.activeBindings[i] = state.bsBindingState.isBound(i) ? VK_TRUE : VK_FALSE;
specData.activeBindings[i] = state.bsBindingMask.isBound(i) ? VK_TRUE : VK_FALSE;
VkSpecializationInfo specInfo;
specInfo.mapEntryCount = g_specConstantMap.mapEntryCount();

View File

@ -2,7 +2,7 @@
#include <vector>
#include "dxvk_binding.h"
#include "dxvk_bind_mask.h"
#include "dxvk_pipecache.h"
#include "dxvk_pipelayout.h"
#include "dxvk_resource.h"
@ -20,7 +20,7 @@ namespace dxvk {
bool operator == (const DxvkComputePipelineStateInfo& other) const;
bool operator != (const DxvkComputePipelineStateInfo& other) const;
DxvkBindingState bsBindingState;
DxvkBindingMask bsBindingMask;
};

View File

@ -1902,7 +1902,7 @@ namespace dxvk {
if (m_flags.test(DxvkContextFlag::CpDirtyPipeline)) {
m_flags.clr(DxvkContextFlag::CpDirtyPipeline);
m_state.cp.state.bsBindingState.clear();
m_state.cp.state.bsBindingMask.clear();
m_state.cp.pipeline = m_pipeMgr->createComputePipeline(m_state.cp.cs.shader);
if (m_state.cp.pipeline != nullptr)
@ -1944,7 +1944,7 @@ namespace dxvk {
if (m_flags.test(DxvkContextFlag::GpDirtyPipeline)) {
m_flags.clr(DxvkContextFlag::GpDirtyPipeline);
m_state.gp.state.bsBindingState.clear();
m_state.gp.state.bsBindingMask.clear();
m_state.gp.pipeline = m_pipeMgr->createGraphicsPipeline(
m_state.gp.vs.shader,
m_state.gp.tcs.shader, m_state.gp.tes.shader,
@ -2003,6 +2003,7 @@ namespace dxvk {
this->updateShaderResources(
VK_PIPELINE_BIND_POINT_COMPUTE,
m_state.cp.state.bsBindingMask,
m_state.cp.pipeline->layout());
m_flags.set(
@ -2019,7 +2020,6 @@ namespace dxvk {
if (m_flags.test(DxvkContextFlag::CpDirtyDescriptorSet)) {
m_cpSet = this->updateShaderDescriptors(
VK_PIPELINE_BIND_POINT_COMPUTE,
m_state.cp.state.bsBindingState,
m_state.cp.pipeline->layout());
}
@ -2046,6 +2046,7 @@ namespace dxvk {
this->updateShaderResources(
VK_PIPELINE_BIND_POINT_GRAPHICS,
m_state.gp.state.bsBindingMask,
m_state.gp.pipeline->layout());
m_flags.set(
@ -2062,7 +2063,6 @@ namespace dxvk {
if (m_flags.test(DxvkContextFlag::GpDirtyDescriptorSet)) {
m_gpSet = this->updateShaderDescriptors(
VK_PIPELINE_BIND_POINT_GRAPHICS,
m_state.gp.state.bsBindingState,
m_state.gp.pipeline->layout());
}
@ -2080,12 +2080,8 @@ namespace dxvk {
void DxvkContext::updateShaderResources(
VkPipelineBindPoint bindPoint,
DxvkBindingMask& bindMask,
const DxvkPipelineLayout* layout) {
DxvkBindingState& bindingState =
bindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS
? m_state.gp.state.bsBindingState
: m_state.cp.state.bsBindingState;
bool updatePipelineState = false;
DxvkAttachment depthAttachment;
@ -2100,7 +2096,7 @@ namespace dxvk {
switch (binding.type) {
case VK_DESCRIPTOR_TYPE_SAMPLER:
if (res.sampler != nullptr) {
updatePipelineState |= bindingState.setBound(i);
updatePipelineState |= bindMask.setBound(i);
m_descInfos[i].image.sampler = res.sampler->handle();
m_descInfos[i].image.imageView = VK_NULL_HANDLE;
@ -2108,14 +2104,14 @@ namespace dxvk {
m_cmd->trackResource(res.sampler);
} else {
updatePipelineState |= bindingState.setUnbound(i);
updatePipelineState |= bindMask.setUnbound(i);
m_descInfos[i].image = m_device->dummySamplerDescriptor();
} break;
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
if (res.imageView != nullptr && res.imageView->handle(binding.view) != VK_NULL_HANDLE) {
updatePipelineState |= bindingState.setBound(i);
updatePipelineState |= bindMask.setBound(i);
m_descInfos[i].image.sampler = VK_NULL_HANDLE;
m_descInfos[i].image.imageView = res.imageView->handle(binding.view);
@ -2128,14 +2124,14 @@ namespace dxvk {
m_cmd->trackResource(res.imageView);
m_cmd->trackResource(res.imageView->image());
} else {
updatePipelineState |= bindingState.setUnbound(i);
updatePipelineState |= bindMask.setUnbound(i);
m_descInfos[i].image = m_device->dummyImageViewDescriptor(binding.view);
} break;
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
if (res.bufferView != nullptr) {
updatePipelineState |= bindingState.setBound(i);
updatePipelineState |= bindMask.setBound(i);
res.bufferView->updateView();
m_descInfos[i].texelBuffer = res.bufferView->handle();
@ -2143,14 +2139,14 @@ namespace dxvk {
m_cmd->trackResource(res.bufferView->viewResource());
m_cmd->trackResource(res.bufferView->bufferResource());
} else {
updatePipelineState |= bindingState.setUnbound(i);
updatePipelineState |= bindMask.setUnbound(i);
m_descInfos[i].texelBuffer = m_device->dummyBufferViewDescriptor();
} break;
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
if (res.bufferSlice.defined()) {
updatePipelineState |= bindingState.setBound(i);
updatePipelineState |= bindMask.setBound(i);
auto physicalSlice = res.bufferSlice.physicalSlice();
m_descInfos[i].buffer.buffer = physicalSlice.handle();
@ -2159,14 +2155,14 @@ namespace dxvk {
m_cmd->trackResource(physicalSlice.resource());
} else {
updatePipelineState |= bindingState.setUnbound(i);
updatePipelineState |= bindMask.setUnbound(i);
m_descInfos[i].buffer = m_device->dummyBufferDescriptor();
} break;
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
if (res.bufferSlice.defined()) {
updatePipelineState |= bindingState.setBound(i);
updatePipelineState |= bindMask.setBound(i);
auto physicalSlice = res.bufferSlice.physicalSlice();
m_descInfos[i].buffer.buffer = physicalSlice.handle();
@ -2175,7 +2171,7 @@ namespace dxvk {
m_cmd->trackResource(physicalSlice.resource());
} else {
updatePipelineState |= bindingState.setUnbound(i);
updatePipelineState |= bindMask.setUnbound(i);
m_descInfos[i].buffer = m_device->dummyBufferDescriptor();
} break;
@ -2194,7 +2190,6 @@ namespace dxvk {
VkDescriptorSet DxvkContext::updateShaderDescriptors(
VkPipelineBindPoint bindPoint,
const DxvkBindingState& bindingState,
const DxvkPipelineLayout* layout) {
VkDescriptorSet descriptorSet = VK_NULL_HANDLE;
@ -2411,7 +2406,7 @@ namespace dxvk {
bool requiresBarrier = false;
for (uint32_t i = 0; i < layout->bindingCount() && !requiresBarrier; i++) {
if (m_state.cp.state.bsBindingState.isBound(i)) {
if (m_state.cp.state.bsBindingMask.isBound(i)) {
const DxvkDescriptorSlot binding = layout->binding(i);
const DxvkShaderResourceSlot& slot = m_rc[binding.slot];
@ -2464,7 +2459,7 @@ namespace dxvk {
auto layout = m_state.cp.pipeline->layout();
for (uint32_t i = 0; i < layout->bindingCount(); i++) {
if (m_state.cp.state.bsBindingState.isBound(i)) {
if (m_state.cp.state.bsBindingMask.isBound(i)) {
const DxvkDescriptorSlot binding = layout->binding(i);
const DxvkShaderResourceSlot& slot = m_rc[binding.slot];

View File

@ -1,7 +1,7 @@
#pragma once
#include "dxvk_barrier.h"
#include "dxvk_binding.h"
#include "dxvk_bind_mask.h"
#include "dxvk_cmdlist.h"
#include "dxvk_context_state.h"
#include "dxvk_data.h"
@ -701,11 +701,11 @@ namespace dxvk {
void updateShaderResources(
VkPipelineBindPoint bindPoint,
DxvkBindingMask& bindMask,
const DxvkPipelineLayout* layout);
VkDescriptorSet updateShaderDescriptors(
VkPipelineBindPoint bindPoint,
const DxvkBindingState& bindingState,
const DxvkPipelineLayout* layout);
void updateShaderDescriptorSetBinding(

View File

@ -165,7 +165,7 @@ namespace dxvk {
specData.rasterizerSampleCount = uint32_t(state.msSampleCount);
for (uint32_t i = 0; i < MaxNumActiveBindings; i++)
specData.activeBindings[i] = state.bsBindingState.isBound(i) ? VK_TRUE : VK_FALSE;
specData.activeBindings[i] = state.bsBindingMask.isBound(i) ? VK_TRUE : VK_FALSE;
VkSpecializationInfo specInfo;
specInfo.mapEntryCount = g_specConstantMap.mapEntryCount();

View File

@ -2,7 +2,7 @@
#include <mutex>
#include "dxvk_binding.h"
#include "dxvk_bind_mask.h"
#include "dxvk_constant_state.h"
#include "dxvk_pipecache.h"
#include "dxvk_pipelayout.h"
@ -34,7 +34,7 @@ namespace dxvk {
bool operator == (const DxvkGraphicsPipelineStateInfo& other) const;
bool operator != (const DxvkGraphicsPipelineStateInfo& other) const;
DxvkBindingState bsBindingState;
DxvkBindingMask bsBindingMask;
VkPrimitiveTopology iaPrimitiveTopology;
VkBool32 iaPrimitiveRestart;