1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-19 05:52:11 +01:00

[dxvk] Store compressed shader modules in DxvkShader

Reduces the amount of memory used to store shaders to
around ~45%-50% of the original size.
This commit is contained in:
Philip Rebohle 2019-04-04 02:51:16 +02:00
parent f49863f321
commit ac3cd0b688
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 7 additions and 6 deletions

View File

@ -92,7 +92,7 @@ namespace dxvk {
uint32_t slotCount,
const DxvkResourceSlot* slotInfos,
const DxvkInterfaceSlots& iface,
const SpirvCodeBuffer& code,
SpirvCodeBuffer code,
const DxvkShaderOptions& options,
DxvkShaderConstData&& constData)
: m_stage(stage), m_code(code), m_interface(iface),
@ -105,7 +105,7 @@ namespace dxvk {
// are stored so we can quickly remap them.
uint32_t o1VarId = 0;
for (auto ins : m_code) {
for (auto ins : code) {
if (ins.opCode() == spv::OpDecorate) {
if (ins.arg(2) == spv::DecorationBinding
|| ins.arg(2) == spv::DecorationSpecId)
@ -151,7 +151,7 @@ namespace dxvk {
const Rc<vk::DeviceFn>& vkd,
const DxvkDescriptorSlotMapping& mapping,
const DxvkShaderModuleCreateInfo& info) {
SpirvCodeBuffer spirvCode = m_code;
SpirvCodeBuffer spirvCode = m_code.decompress();
uint32_t* code = spirvCode.data();
// Remap resource binding IDs
@ -170,7 +170,7 @@ namespace dxvk {
void DxvkShader::dump(std::ostream& outputStream) const {
m_code.store(outputStream);
m_code.decompress().store(outputStream);
}
}

View File

@ -8,6 +8,7 @@
#include "dxvk_shader_key.h"
#include "../spirv/spirv_code_buffer.h"
#include "../spirv/spirv_compression.h"
namespace dxvk {
@ -130,7 +131,7 @@ namespace dxvk {
uint32_t slotCount,
const DxvkResourceSlot* slotInfos,
const DxvkInterfaceSlots& iface,
const SpirvCodeBuffer& code,
SpirvCodeBuffer code,
const DxvkShaderOptions& options,
DxvkShaderConstData&& constData);
@ -246,7 +247,7 @@ namespace dxvk {
private:
VkShaderStageFlagBits m_stage;
SpirvCodeBuffer m_code;
SpirvCompressedBuffer m_code;
std::vector<DxvkResourceSlot> m_slots;
std::vector<size_t> m_idOffsets;