mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 14:52:11 +01:00
[dxvk] Add more generic version of DxvkBindingMask
This commit is contained in:
parent
f58242c58d
commit
924ca9eaec
@ -16,9 +16,10 @@ namespace dxvk {
|
|||||||
* binding-related specialization constants in shaders.
|
* binding-related specialization constants in shaders.
|
||||||
* \tparam N Number of binding slots
|
* \tparam N Number of binding slots
|
||||||
*/
|
*/
|
||||||
class DxvkBindingMask {
|
template<uint32_t BindingCount>
|
||||||
|
class DxvkBindingSet {
|
||||||
constexpr static uint32_t BitCount = 32;
|
constexpr static uint32_t BitCount = 32;
|
||||||
constexpr static uint32_t IntCount = (MaxNumActiveBindings + BitCount - 1) / BitCount;
|
constexpr static uint32_t IntCount = (BindingCount + BitCount - 1) / BitCount;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,7 +28,7 @@ namespace dxvk {
|
|||||||
* \param [in] slot The binding ID
|
* \param [in] slot The binding ID
|
||||||
* \returns \c true if the binding is active
|
* \returns \c true if the binding is active
|
||||||
*/
|
*/
|
||||||
bool isBound(uint32_t slot) const {
|
bool test(uint32_t slot) const {
|
||||||
const uint32_t intId = slot / BitCount;
|
const uint32_t intId = slot / BitCount;
|
||||||
const uint32_t bitId = slot % BitCount;
|
const uint32_t bitId = slot % BitCount;
|
||||||
const uint32_t bitMask = 1u << bitId;
|
const uint32_t bitMask = 1u << bitId;
|
||||||
@ -40,7 +41,7 @@ namespace dxvk {
|
|||||||
* \param [in] slot The binding ID
|
* \param [in] slot The binding ID
|
||||||
* \returns \c true if the state has changed
|
* \returns \c true if the state has changed
|
||||||
*/
|
*/
|
||||||
bool setBound(uint32_t slot) {
|
bool set(uint32_t slot) {
|
||||||
const uint32_t intId = slot / BitCount;
|
const uint32_t intId = slot / BitCount;
|
||||||
const uint32_t bitId = slot % BitCount;
|
const uint32_t bitId = slot % BitCount;
|
||||||
const uint32_t bitMask = 1u << bitId;
|
const uint32_t bitMask = 1u << bitId;
|
||||||
@ -56,7 +57,7 @@ namespace dxvk {
|
|||||||
* \param [in] slot The binding ID
|
* \param [in] slot The binding ID
|
||||||
* \returns \c true if the state has changed
|
* \returns \c true if the state has changed
|
||||||
*/
|
*/
|
||||||
bool setUnbound(uint32_t slot) {
|
bool clr(uint32_t slot) {
|
||||||
const uint32_t intId = slot / BitCount;
|
const uint32_t intId = slot / BitCount;
|
||||||
const uint32_t bitId = slot % BitCount;
|
const uint32_t bitId = slot % BitCount;
|
||||||
const uint32_t bitMask = 1u << bitId;
|
const uint32_t bitMask = 1u << bitId;
|
||||||
@ -82,6 +83,8 @@ namespace dxvk {
|
|||||||
uint32_t m_slots[IntCount];
|
uint32_t m_slots[IntCount];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using DxvkBindingMask = DxvkBindingSet<MaxNumActiveBindings>;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,7 +95,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
DxvkSpecConstants specData;
|
DxvkSpecConstants specData;
|
||||||
for (uint32_t i = 0; i < m_layout->bindingCount(); i++)
|
for (uint32_t i = 0; i < m_layout->bindingCount(); i++)
|
||||||
specData.set(i, state.bsBindingMask.isBound(i), true);
|
specData.set(i, state.bsBindingMask.test(i), true);
|
||||||
|
|
||||||
VkSpecializationInfo specInfo = specData.getSpecInfo();
|
VkSpecializationInfo specInfo = specData.getSpecInfo();
|
||||||
|
|
||||||
|
@ -3543,7 +3543,7 @@ namespace dxvk {
|
|||||||
switch (binding.type) {
|
switch (binding.type) {
|
||||||
case VK_DESCRIPTOR_TYPE_SAMPLER:
|
case VK_DESCRIPTOR_TYPE_SAMPLER:
|
||||||
if (res.sampler != nullptr) {
|
if (res.sampler != nullptr) {
|
||||||
updatePipelineState |= bindMask.setBound(i);
|
updatePipelineState |= bindMask.set(i);
|
||||||
|
|
||||||
m_descInfos[i].image.sampler = res.sampler->handle();
|
m_descInfos[i].image.sampler = res.sampler->handle();
|
||||||
m_descInfos[i].image.imageView = VK_NULL_HANDLE;
|
m_descInfos[i].image.imageView = VK_NULL_HANDLE;
|
||||||
@ -3551,14 +3551,14 @@ namespace dxvk {
|
|||||||
|
|
||||||
m_cmd->trackResource(res.sampler);
|
m_cmd->trackResource(res.sampler);
|
||||||
} else {
|
} else {
|
||||||
updatePipelineState |= bindMask.setUnbound(i);
|
updatePipelineState |= bindMask.clr(i);
|
||||||
m_descInfos[i].image = m_device->dummySamplerDescriptor();
|
m_descInfos[i].image = m_device->dummySamplerDescriptor();
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
|
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
|
||||||
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
|
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
|
||||||
if (res.imageView != nullptr && res.imageView->handle(binding.view) != VK_NULL_HANDLE) {
|
if (res.imageView != nullptr && res.imageView->handle(binding.view) != VK_NULL_HANDLE) {
|
||||||
updatePipelineState |= bindMask.setBound(i);
|
updatePipelineState |= bindMask.set(i);
|
||||||
|
|
||||||
m_descInfos[i].image.sampler = VK_NULL_HANDLE;
|
m_descInfos[i].image.sampler = VK_NULL_HANDLE;
|
||||||
m_descInfos[i].image.imageView = res.imageView->handle(binding.view);
|
m_descInfos[i].image.imageView = res.imageView->handle(binding.view);
|
||||||
@ -3570,14 +3570,14 @@ namespace dxvk {
|
|||||||
m_cmd->trackResource(res.imageView);
|
m_cmd->trackResource(res.imageView);
|
||||||
m_cmd->trackResource(res.imageView->image());
|
m_cmd->trackResource(res.imageView->image());
|
||||||
} else {
|
} else {
|
||||||
updatePipelineState |= bindMask.setUnbound(i);
|
updatePipelineState |= bindMask.clr(i);
|
||||||
m_descInfos[i].image = m_device->dummyImageViewDescriptor(binding.view);
|
m_descInfos[i].image = m_device->dummyImageViewDescriptor(binding.view);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
|
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
|
||||||
if (res.sampler != nullptr && res.imageView != nullptr
|
if (res.sampler != nullptr && res.imageView != nullptr
|
||||||
&& res.imageView->handle(binding.view) != VK_NULL_HANDLE) {
|
&& res.imageView->handle(binding.view) != VK_NULL_HANDLE) {
|
||||||
updatePipelineState |= bindMask.setBound(i);
|
updatePipelineState |= bindMask.set(i);
|
||||||
|
|
||||||
m_descInfos[i].image.sampler = res.sampler->handle();
|
m_descInfos[i].image.sampler = res.sampler->handle();
|
||||||
m_descInfos[i].image.imageView = res.imageView->handle(binding.view);
|
m_descInfos[i].image.imageView = res.imageView->handle(binding.view);
|
||||||
@ -3590,14 +3590,14 @@ namespace dxvk {
|
|||||||
m_cmd->trackResource(res.imageView);
|
m_cmd->trackResource(res.imageView);
|
||||||
m_cmd->trackResource(res.imageView->image());
|
m_cmd->trackResource(res.imageView->image());
|
||||||
} else {
|
} else {
|
||||||
updatePipelineState |= bindMask.setUnbound(i);
|
updatePipelineState |= bindMask.clr(i);
|
||||||
m_descInfos[i].image = m_device->dummyImageSamplerDescriptor(binding.view);
|
m_descInfos[i].image = m_device->dummyImageSamplerDescriptor(binding.view);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
|
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
|
||||||
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
|
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
|
||||||
if (res.bufferView != nullptr) {
|
if (res.bufferView != nullptr) {
|
||||||
updatePipelineState |= bindMask.setBound(i);
|
updatePipelineState |= bindMask.set(i);
|
||||||
|
|
||||||
res.bufferView->updateView();
|
res.bufferView->updateView();
|
||||||
m_descInfos[i].texelBuffer = res.bufferView->handle();
|
m_descInfos[i].texelBuffer = res.bufferView->handle();
|
||||||
@ -3605,32 +3605,32 @@ namespace dxvk {
|
|||||||
m_cmd->trackResource(res.bufferView);
|
m_cmd->trackResource(res.bufferView);
|
||||||
m_cmd->trackResource(res.bufferView->buffer());
|
m_cmd->trackResource(res.bufferView->buffer());
|
||||||
} else {
|
} else {
|
||||||
updatePipelineState |= bindMask.setUnbound(i);
|
updatePipelineState |= bindMask.clr(i);
|
||||||
m_descInfos[i].texelBuffer = m_device->dummyBufferViewDescriptor();
|
m_descInfos[i].texelBuffer = m_device->dummyBufferViewDescriptor();
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
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.defined()) {
|
if (res.bufferSlice.defined()) {
|
||||||
updatePipelineState |= bindMask.setBound(i);
|
updatePipelineState |= bindMask.set(i);
|
||||||
m_descInfos[i] = res.bufferSlice.getDescriptor();
|
m_descInfos[i] = res.bufferSlice.getDescriptor();
|
||||||
|
|
||||||
m_cmd->trackResource(res.bufferSlice.buffer());
|
m_cmd->trackResource(res.bufferSlice.buffer());
|
||||||
} else {
|
} else {
|
||||||
updatePipelineState |= bindMask.setUnbound(i);
|
updatePipelineState |= bindMask.clr(i);
|
||||||
m_descInfos[i].buffer = m_device->dummyBufferDescriptor();
|
m_descInfos[i].buffer = m_device->dummyBufferDescriptor();
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
|
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
|
||||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
|
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
|
||||||
if (res.bufferSlice.defined()) {
|
if (res.bufferSlice.defined()) {
|
||||||
updatePipelineState |= bindMask.setBound(i);
|
updatePipelineState |= bindMask.set(i);
|
||||||
m_descInfos[i] = res.bufferSlice.getDescriptor();
|
m_descInfos[i] = res.bufferSlice.getDescriptor();
|
||||||
m_descInfos[i].buffer.offset = 0;
|
m_descInfos[i].buffer.offset = 0;
|
||||||
|
|
||||||
m_cmd->trackResource(res.bufferSlice.buffer());
|
m_cmd->trackResource(res.bufferSlice.buffer());
|
||||||
} else {
|
} else {
|
||||||
updatePipelineState |= bindMask.setUnbound(i);
|
updatePipelineState |= bindMask.clr(i);
|
||||||
m_descInfos[i].buffer = m_device->dummyBufferDescriptor();
|
m_descInfos[i].buffer = m_device->dummyBufferDescriptor();
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -3992,7 +3992,7 @@ namespace dxvk {
|
|||||||
bool requiresBarrier = false;
|
bool requiresBarrier = false;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < layout->bindingCount() && !requiresBarrier; i++) {
|
for (uint32_t i = 0; i < layout->bindingCount() && !requiresBarrier; i++) {
|
||||||
if (m_state.cp.state.bsBindingMask.isBound(i)) {
|
if (m_state.cp.state.bsBindingMask.test(i)) {
|
||||||
const DxvkDescriptorSlot binding = layout->binding(i);
|
const DxvkDescriptorSlot binding = layout->binding(i);
|
||||||
const DxvkShaderResourceSlot& slot = m_rc[binding.slot];
|
const DxvkShaderResourceSlot& slot = m_rc[binding.slot];
|
||||||
|
|
||||||
@ -4061,7 +4061,7 @@ namespace dxvk {
|
|||||||
auto layout = m_state.cp.pipeline->layout();
|
auto layout = m_state.cp.pipeline->layout();
|
||||||
|
|
||||||
for (uint32_t i = 0; i < layout->bindingCount(); i++) {
|
for (uint32_t i = 0; i < layout->bindingCount(); i++) {
|
||||||
if (m_state.cp.state.bsBindingMask.isBound(i)) {
|
if (m_state.cp.state.bsBindingMask.test(i)) {
|
||||||
const DxvkDescriptorSlot binding = layout->binding(i);
|
const DxvkDescriptorSlot binding = layout->binding(i);
|
||||||
const DxvkShaderResourceSlot& slot = m_rc[binding.slot];
|
const DxvkShaderResourceSlot& slot = m_rc[binding.slot];
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ namespace dxvk {
|
|||||||
specData.set(uint32_t(DxvkSpecConstantId::RasterizerSampleCount), sampleCount, VK_SAMPLE_COUNT_1_BIT);
|
specData.set(uint32_t(DxvkSpecConstantId::RasterizerSampleCount), sampleCount, VK_SAMPLE_COUNT_1_BIT);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < m_layout->bindingCount(); i++)
|
for (uint32_t i = 0; i < m_layout->bindingCount(); i++)
|
||||||
specData.set(i, state.bsBindingMask.isBound(i), true);
|
specData.set(i, state.bsBindingMask.test(i), true);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < MaxNumRenderTargets; i++) {
|
for (uint32_t i = 0; i < MaxNumRenderTargets; i++) {
|
||||||
if ((m_fsOut & (1 << i)) != 0) {
|
if ((m_fsOut & (1 << i)) != 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user