mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[dxvk] Add spec constants for pixel shader output mapping
This commit is contained in:
parent
37a8743dbc
commit
cb274e040d
@ -237,6 +237,11 @@ namespace dxvk {
|
|||||||
omBlendAttachments[i].colorWriteMask = util::remapComponentMask(
|
omBlendAttachments[i].colorWriteMask = util::remapComponentMask(
|
||||||
state.omBlendAttachments[i].colorWriteMask,
|
state.omBlendAttachments[i].colorWriteMask,
|
||||||
state.omComponentMapping[i]);
|
state.omComponentMapping[i]);
|
||||||
|
|
||||||
|
specData.outputMappings[4 * i + 0] = util::getComponentIndex(state.omComponentMapping[i].r, 0);
|
||||||
|
specData.outputMappings[4 * i + 1] = util::getComponentIndex(state.omComponentMapping[i].g, 1);
|
||||||
|
specData.outputMappings[4 * i + 2] = util::getComponentIndex(state.omComponentMapping[i].b, 2);
|
||||||
|
specData.outputMappings[4 * i + 3] = util::getComponentIndex(state.omComponentMapping[i].a, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate per-instance attribute divisors
|
// Generate per-instance attribute divisors
|
||||||
|
@ -21,7 +21,12 @@ namespace dxvk {
|
|||||||
*/
|
*/
|
||||||
enum class DxvkSpecConstantId : uint32_t {
|
enum class DxvkSpecConstantId : uint32_t {
|
||||||
RasterizerSampleCount = 0x10000,
|
RasterizerSampleCount = 0x10000,
|
||||||
|
|
||||||
|
/// Special constant ranges that do not count
|
||||||
|
/// towards the spec constant min/max values
|
||||||
|
ColorComponentMappings = 0x20000,
|
||||||
|
|
||||||
|
/// Lowest and highest known spec constant IDs
|
||||||
SpecConstantIdMin = RasterizerSampleCount,
|
SpecConstantIdMin = RasterizerSampleCount,
|
||||||
SpecConstantIdMax = RasterizerSampleCount,
|
SpecConstantIdMax = RasterizerSampleCount,
|
||||||
};
|
};
|
||||||
|
@ -11,9 +11,12 @@ namespace dxvk {
|
|||||||
|
|
||||||
DxvkSpecConstantMap::DxvkSpecConstantMap() {
|
DxvkSpecConstantMap::DxvkSpecConstantMap() {
|
||||||
SET_CONSTANT_ENTRY(DxvkSpecConstantId::RasterizerSampleCount, rasterizerSampleCount);
|
SET_CONSTANT_ENTRY(DxvkSpecConstantId::RasterizerSampleCount, rasterizerSampleCount);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < MaxNumActiveBindings; i++)
|
for (uint32_t i = 0; i < MaxNumActiveBindings; i++)
|
||||||
this->setBindingEntry(i);
|
this->setBindingEntry(i);
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < MaxNumRenderTargets; i++)
|
||||||
|
this->setOutputMappingEntry(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -27,8 +30,8 @@ namespace dxvk {
|
|||||||
entry.size = size;
|
entry.size = size;
|
||||||
m_mapEntries[uint32_t(specId) - uint32_t(DxvkSpecConstantId::SpecConstantIdMin)] = entry;
|
m_mapEntries[uint32_t(specId) - uint32_t(DxvkSpecConstantId::SpecConstantIdMin)] = entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkSpecConstantMap::setBindingEntry(
|
void DxvkSpecConstantMap::setBindingEntry(
|
||||||
uint32_t binding) {
|
uint32_t binding) {
|
||||||
VkSpecializationMapEntry entry;
|
VkSpecializationMapEntry entry;
|
||||||
@ -37,5 +40,19 @@ namespace dxvk {
|
|||||||
entry.size = sizeof(VkBool32);
|
entry.size = sizeof(VkBool32);
|
||||||
m_mapEntries[MaxNumSpecConstants + binding] = entry;
|
m_mapEntries[MaxNumSpecConstants + binding] = entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DxvkSpecConstantMap::setOutputMappingEntry(
|
||||||
|
uint32_t output) {
|
||||||
|
for (uint32_t i = 0; i < 4; i++) {
|
||||||
|
uint32_t constId = 4 * output + i;
|
||||||
|
|
||||||
|
VkSpecializationMapEntry entry;
|
||||||
|
entry.constantID = uint32_t(DxvkSpecConstantId::ColorComponentMappings) + constId;
|
||||||
|
entry.offset = sizeof(uint32_t) * constId + offsetof(DxvkSpecConstantData, outputMappings);
|
||||||
|
entry.size = sizeof(uint32_t);
|
||||||
|
m_mapEntries[MaxNumSpecConstants + MaxNumActiveBindings + constId] = entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -18,6 +18,7 @@ namespace dxvk {
|
|||||||
*/
|
*/
|
||||||
struct DxvkSpecConstantData {
|
struct DxvkSpecConstantData {
|
||||||
uint32_t rasterizerSampleCount;
|
uint32_t rasterizerSampleCount;
|
||||||
|
uint32_t outputMappings[MaxNumRenderTargets * 4];
|
||||||
VkBool32 activeBindings[MaxNumActiveBindings];
|
VkBool32 activeBindings[MaxNumActiveBindings];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -55,7 +56,10 @@ namespace dxvk {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::array<VkSpecializationMapEntry, MaxNumSpecConstants + MaxNumActiveBindings> m_mapEntries;
|
std::array<VkSpecializationMapEntry,
|
||||||
|
MaxNumSpecConstants +
|
||||||
|
MaxNumActiveBindings +
|
||||||
|
MaxNumRenderTargets * 4> m_mapEntries;
|
||||||
|
|
||||||
void setConstantEntry(
|
void setConstantEntry(
|
||||||
DxvkSpecConstantId specId,
|
DxvkSpecConstantId specId,
|
||||||
@ -65,6 +69,9 @@ namespace dxvk {
|
|||||||
void setBindingEntry(
|
void setBindingEntry(
|
||||||
uint32_t binding);
|
uint32_t binding);
|
||||||
|
|
||||||
|
void setOutputMappingEntry(
|
||||||
|
uint32_t output);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern DxvkSpecConstantMap g_specConstantMap;
|
extern DxvkSpecConstantMap g_specConstantMap;
|
||||||
|
@ -136,4 +136,17 @@ namespace dxvk::util {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t getComponentIndex(
|
||||||
|
VkComponentSwizzle component,
|
||||||
|
uint32_t identity) {
|
||||||
|
switch (component) {
|
||||||
|
case VK_COMPONENT_SWIZZLE_R: return 0;
|
||||||
|
case VK_COMPONENT_SWIZZLE_G: return 1;
|
||||||
|
case VK_COMPONENT_SWIZZLE_B: return 2;
|
||||||
|
case VK_COMPONENT_SWIZZLE_A: return 3;
|
||||||
|
default: return identity; /* identity, zero, one */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -201,6 +201,17 @@ namespace dxvk::util {
|
|||||||
VkComponentMapping invertComponentMapping(
|
VkComponentMapping invertComponentMapping(
|
||||||
VkComponentMapping mapping);
|
VkComponentMapping mapping);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Computes component index for a component swizzle
|
||||||
|
*
|
||||||
|
* \param [in] component The component swizzle
|
||||||
|
* \param [in] identity Value for SWIZZLE_IDENTITY
|
||||||
|
* \returns Component index
|
||||||
|
*/
|
||||||
|
uint32_t getComponentIndex(
|
||||||
|
VkComponentSwizzle component,
|
||||||
|
uint32_t identity);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user