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

[dxvk] Prepare for pipeline state changes and bump cache format to v7

One of the changes includes hard-coding certain constants into the old
pipeline state structs, since changing the constants would invalidate
any old state cache and making the conversion pointless.
This commit is contained in:
Philip Rebohle 2019-10-07 11:10:57 +02:00
parent 32dff89b2d
commit 9dad44a6b1
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 116 additions and 25 deletions

View File

@ -302,6 +302,8 @@ namespace dxvk {
expectedSize = sizeof(DxvkStateCacheEntryV4);
else if (curHeader.version <= 5)
expectedSize = sizeof(DxvkStateCacheEntryV5);
else if (curHeader.version <= 6)
expectedSize = sizeof(DxvkStateCacheEntryV6);
if (curHeader.entrySize != expectedSize) {
Logger::warn("DXVK: State cache entry size changed");
@ -383,23 +385,34 @@ namespace dxvk {
uint32_t version,
std::istream& stream,
DxvkStateCacheEntry& entry) const {
if (version <= 4) {
DxvkStateCacheEntryV4 v4;
if (version <= 6) {
DxvkStateCacheEntryV6 v6;
if (!readCacheEntryTyped(stream, v4))
return false;
if (version == 2)
convertEntryV2(v4);
return convertEntryV4(v4, entry);
} else if (version <= 5) {
DxvkStateCacheEntryV5 v5;
if (version <= 4) {
DxvkStateCacheEntryV4 v4;
if (!readCacheEntryTyped(stream, v5))
return false;
if (!readCacheEntryTyped(stream, v4))
return false;
return convertEntryV5(v5, entry);
if (version == 2)
convertEntryV2(v4);
if (!convertEntryV4(v4, v6))
return false;
} else if (version <= 5) {
DxvkStateCacheEntryV5 v5;
if (!readCacheEntryTyped(stream, v5))
return false;
if (!convertEntryV5(v5, v6))
return false;
} else {
if (!readCacheEntryTyped(stream, v6))
return false;
}
return convertEntryV6(v6, entry);
} else {
return readCacheEntryTyped(stream, entry);
}
@ -435,7 +448,7 @@ namespace dxvk {
bool DxvkStateCache::convertEntryV4(
const DxvkStateCacheEntryV4& in,
DxvkStateCacheEntry& out) const {
DxvkStateCacheEntryV6& out) const {
out.shaders = in.shaders;
out.format = in.format;
out.hash = in.hash;
@ -480,7 +493,7 @@ namespace dxvk {
out.gpState.omEnableLogicOp = in.gpState.omEnableLogicOp;
out.gpState.omLogicOp = in.gpState.omLogicOp;
for (uint32_t i = 0; i < MaxNumRenderTargets; i++) {
for (uint32_t i = 0; i < 8; i++) {
out.gpState.omBlendAttachments[i] = in.gpState.omBlendAttachments[i];
out.gpState.omComponentMapping[i] = in.gpState.omComponentMapping[i];
}
@ -491,7 +504,7 @@ namespace dxvk {
bool DxvkStateCache::convertEntryV5(
const DxvkStateCacheEntryV5& in,
DxvkStateCacheEntry& out) const {
DxvkStateCacheEntryV6& out) const {
out.shaders = in.shaders;
out.gpState = in.gpState;
out.format = in.format;
@ -502,6 +515,14 @@ namespace dxvk {
}
bool DxvkStateCache::convertEntryV6(
const DxvkStateCacheEntryV6& in,
DxvkStateCacheEntry& out) const {
/* TODO implement */
return false;
}
void DxvkStateCache::workerFunc() {
env::setThreadName("dxvk-shader");

View File

@ -157,10 +157,14 @@ namespace dxvk {
bool convertEntryV4(
const DxvkStateCacheEntryV4& in,
DxvkStateCacheEntry& out) const;
DxvkStateCacheEntryV6& out) const;
bool convertEntryV5(
const DxvkStateCacheEntryV5& in,
DxvkStateCacheEntryV6& out) const;
bool convertEntryV6(
const DxvkStateCacheEntryV6& in,
DxvkStateCacheEntry& out) const;
void workerFunc();

View File

@ -52,7 +52,7 @@ namespace dxvk {
*/
struct DxvkStateCacheHeader {
char magic[4] = { 'D', 'X', 'V', 'K' };
uint32_t version = 6;
uint32_t version = 7;
uint32_t entrySize = sizeof(DxvkStateCacheEntry);
};
@ -71,9 +71,9 @@ namespace dxvk {
uint32_t ilAttributeCount;
uint32_t ilBindingCount;
VkVertexInputAttributeDescription ilAttributes[DxvkLimits::MaxNumVertexAttributes];
VkVertexInputBindingDescription ilBindings[DxvkLimits::MaxNumVertexBindings];
uint32_t ilDivisors[DxvkLimits::MaxNumVertexBindings];
VkVertexInputAttributeDescription ilAttributes[32];
VkVertexInputBindingDescription ilBindings[32];
uint32_t ilDivisors[32];
VkBool32 rsDepthClipEnable;
VkBool32 rsDepthBiasEnable;
@ -98,8 +98,53 @@ namespace dxvk {
VkBool32 omEnableLogicOp;
VkLogicOp omLogicOp;
VkPipelineColorBlendAttachmentState omBlendAttachments[MaxNumRenderTargets];
VkComponentMapping omComponentMapping[MaxNumRenderTargets];
VkPipelineColorBlendAttachmentState omBlendAttachments[8];
VkComponentMapping omComponentMapping[8];
};
/**
* \brief Version 6 graphics pipeline state
*/
struct DxvkGraphicsPipelineStateInfoV6 {
DxvkBindingMask bsBindingMask;
VkPrimitiveTopology iaPrimitiveTopology;
VkBool32 iaPrimitiveRestart;
uint32_t iaPatchVertexCount;
uint32_t ilAttributeCount;
uint32_t ilBindingCount;
VkVertexInputAttributeDescription ilAttributes[32];
VkVertexInputBindingDescription ilBindings[32];
uint32_t ilDivisors[32];
VkBool32 rsDepthClipEnable;
VkBool32 rsDepthBiasEnable;
VkPolygonMode rsPolygonMode;
VkCullModeFlags rsCullMode;
VkFrontFace rsFrontFace;
uint32_t rsViewportCount;
VkSampleCountFlags rsSampleCount;
VkSampleCountFlags msSampleCount;
uint32_t msSampleMask;
VkBool32 msEnableAlphaToCoverage;
VkBool32 dsEnableDepthTest;
VkBool32 dsEnableDepthWrite;
VkBool32 dsEnableDepthBoundsTest;
VkBool32 dsEnableStencilTest;
VkCompareOp dsDepthCompareOp;
VkStencilOpState dsStencilOpFront;
VkStencilOpState dsStencilOpBack;
VkBool32 omEnableLogicOp;
VkLogicOp omLogicOp;
VkPipelineColorBlendAttachmentState omBlendAttachments[8];
VkComponentMapping omComponentMapping[8];
uint32_t scSpecConstants[8];
};
@ -111,6 +156,15 @@ namespace dxvk {
};
/**
* \brief Version 6 compute pipeline state
*/
struct DxvkComputePipelineStateInfoV6 {
DxvkBindingMask bsBindingMask;
uint32_t scSpecConstants[8];
};
/**
* \brief Version 4 state cache entry
*/
@ -128,10 +182,22 @@ namespace dxvk {
*/
struct DxvkStateCacheEntryV5 {
DxvkStateCacheKey shaders;
DxvkGraphicsPipelineStateInfo gpState;
DxvkGraphicsPipelineStateInfoV6 gpState;
DxvkComputePipelineStateInfoV5 cpState;
DxvkRenderPassFormat format;
Sha1Hash hash;
};
/**
* \brief Version 6 state cache entry
*/
struct DxvkStateCacheEntryV6 {
DxvkStateCacheKey shaders;
DxvkGraphicsPipelineStateInfoV6 gpState;
DxvkComputePipelineStateInfoV6 cpState;
DxvkRenderPassFormat format;
Sha1Hash hash;
};
}