diff --git a/src/dxbc/dxbc_capability.cpp b/src/dxbc/dxbc_capability.cpp deleted file mode 100644 index e717cb6a..00000000 --- a/src/dxbc/dxbc_capability.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "dxbc_capability.h" - -namespace dxvk { - - DxbcCapabilities:: DxbcCapabilities() { } - DxbcCapabilities::~DxbcCapabilities() { } - - - DxvkSpirvCodeBuffer DxbcCapabilities::code() const { - DxvkSpirvCodeBuffer code; - - for (auto cap : m_caps) { - code.putIns (spv::OpCapability, 2); - code.putWord(cap); - } - - return code; - } - - - void DxbcCapabilities::enable(spv::Capability cap) { - m_caps.insert(cap); - } - -} \ No newline at end of file diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp index aef278a6..fc0620a0 100644 --- a/src/dxbc/dxbc_compiler.cpp +++ b/src/dxbc/dxbc_compiler.cpp @@ -21,7 +21,7 @@ namespace dxvk { Rc DxbcCompiler::finalize() { - DxvkSpirvCodeBuffer codeBuffer; + SpirvCodeBuffer codeBuffer; codeBuffer.putHeader(m_counter.numIds()); codeBuffer.append(m_spvCapabilities.code()); codeBuffer.append(m_spvEntryPoints.code()); diff --git a/src/dxbc/dxbc_compiler.h b/src/dxbc/dxbc_compiler.h index 0cf6760b..a81e71ee 100644 --- a/src/dxbc/dxbc_compiler.h +++ b/src/dxbc/dxbc_compiler.h @@ -1,9 +1,10 @@ #pragma once -#include "dxbc_capability.h" #include "dxbc_chunk_shex.h" -#include "dxbc_entrypoint.h" -#include "dxbc_typeinfo.h" + +#include "../spirv/gen/spirv_gen_capability.h" +#include "../spirv/gen/spirv_gen_entrypoint.h" +#include "../spirv/gen/spirv_gen_typeinfo.h" namespace dxvk { @@ -36,12 +37,12 @@ namespace dxvk { private: DxbcProgramVersion m_version; - DxvkSpirvIdCounter m_counter; + SpirvIdCounter m_counter; - DxbcCapabilities m_spvCapabilities; - DxbcEntryPoint m_spvEntryPoints; - DxbcTypeInfo m_spvTypeInfo; - DxvkSpirvCodeBuffer m_spvCode; + SpirvCapabilities m_spvCapabilities; + SpirvEntryPoint m_spvEntryPoints; + SpirvTypeInfo m_spvTypeInfo; + SpirvCodeBuffer m_spvCode; void declareCapabilities(); void declareMemoryModel(); diff --git a/src/dxbc/meson.build b/src/dxbc/meson.build index cc3c8932..d90b5fe6 100644 --- a/src/dxbc/meson.build +++ b/src/dxbc/meson.build @@ -1,14 +1,10 @@ dxbc_src = files([ - 'dxbc_annotation.cpp', - 'dxbc_capability.cpp', 'dxbc_chunk_shex.cpp', 'dxbc_common.cpp', 'dxbc_compiler.cpp', - 'dxbc_entrypoint.cpp', 'dxbc_header.cpp', 'dxbc_module.cpp', 'dxbc_reader.cpp', - 'dxbc_typeinfo.cpp', ]) dxbc_lib = static_library('dxbc', dxbc_src, diff --git a/src/dxvk/dxvk_compute.cpp b/src/dxvk/dxvk_compute.cpp index b0bdb93f..eadb73e0 100644 --- a/src/dxvk/dxvk_compute.cpp +++ b/src/dxvk/dxvk_compute.cpp @@ -39,7 +39,7 @@ namespace dxvk { throw DxvkError("DxvkComputePipeline::DxvkComputePipeline: Failed to create pipeline layout"); } - DxvkSpirvCodeBuffer code = shader->code(0); + SpirvCodeBuffer code = shader->code(0); VkShaderModuleCreateInfo minfo; minfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; diff --git a/src/dxvk/dxvk_shader.cpp b/src/dxvk/dxvk_shader.cpp index 3d344535..c6025877 100644 --- a/src/dxvk/dxvk_shader.cpp +++ b/src/dxvk/dxvk_shader.cpp @@ -4,7 +4,7 @@ namespace dxvk { DxvkShader::DxvkShader( VkShaderStageFlagBits stage, - DxvkSpirvCodeBuffer&& code, + SpirvCodeBuffer&& code, uint32_t numResourceSlots, const DxvkResourceSlot* resourceSlots) : m_stage (stage), @@ -21,7 +21,7 @@ namespace dxvk { } - DxvkSpirvCodeBuffer DxvkShader::code( + SpirvCodeBuffer DxvkShader::code( uint32_t bindingOffset) const { // TODO implement properly if (bindingOffset != 0) diff --git a/src/dxvk/dxvk_shader.h b/src/dxvk/dxvk_shader.h index 5da82b48..3e2a636d 100644 --- a/src/dxvk/dxvk_shader.h +++ b/src/dxvk/dxvk_shader.h @@ -5,7 +5,6 @@ #include "dxvk_include.h" #include "../spirv/spirv_code_buffer.h" -#include "../spirv/spirv_id_counter.h" namespace dxvk { @@ -61,7 +60,7 @@ namespace dxvk { DxvkShader( VkShaderStageFlagBits stage, - DxvkSpirvCodeBuffer&& code, + SpirvCodeBuffer&& code, uint32_t numResourceSlots, const DxvkResourceSlot* resourceSlots); ~DxvkShader(); @@ -76,7 +75,7 @@ namespace dxvk { * \param [in] bindingOffset First binding ID * \returns Modified code buffer */ - DxvkSpirvCodeBuffer code( + SpirvCodeBuffer code( uint32_t bindingOffset) const; /** @@ -114,7 +113,7 @@ namespace dxvk { private: VkShaderStageFlagBits m_stage; - DxvkSpirvCodeBuffer m_code; + SpirvCodeBuffer m_code; std::vector m_slots; diff --git a/src/spirv/gen/spirv_gen_capability.cpp b/src/spirv/gen/spirv_gen_capability.cpp new file mode 100644 index 00000000..ea332847 --- /dev/null +++ b/src/spirv/gen/spirv_gen_capability.cpp @@ -0,0 +1,26 @@ +#include "spirv_gen_capability.h" + +namespace dxvk { + + SpirvCapabilities:: SpirvCapabilities() { } + SpirvCapabilities::~SpirvCapabilities() { } + + + SpirvCodeBuffer SpirvCapabilities::code() const { + return m_code; + } + + + void SpirvCapabilities::enable(spv::Capability cap) { + // Scan the generated instructions to check + // whether we already enabled the capability. + for (auto ins : m_code) { + if (ins.opCode() == spv::OpCapability && ins.arg(1) == cap) + return; + } + + m_code.putIns (spv::OpCapability, 2); + m_code.putWord(cap); + } + +} \ No newline at end of file diff --git a/src/dxbc/dxbc_capability.h b/src/spirv/gen/spirv_gen_capability.h similarity index 76% rename from src/dxbc/dxbc_capability.h rename to src/spirv/gen/spirv_gen_capability.h index 12bc9fbc..b96273dc 100644 --- a/src/dxbc/dxbc_capability.h +++ b/src/spirv/gen/spirv_gen_capability.h @@ -1,8 +1,6 @@ #pragma once -#include - -#include "dxbc_include.h" +#include "../spirv_code_buffer.h" namespace dxvk { @@ -12,12 +10,12 @@ namespace dxvk { * Holds a code buffer solely for the \c OpCapability * instructions in the generated SPIR-V shader module. */ - class DxbcCapabilities { + class SpirvCapabilities { public: - DxbcCapabilities(); - ~DxbcCapabilities(); + SpirvCapabilities(); + ~SpirvCapabilities(); /** * \brief Code buffer @@ -26,7 +24,7 @@ namespace dxvk { * \c OpCapability instructions. * \returns Code buffer */ - DxvkSpirvCodeBuffer code() const; + SpirvCodeBuffer code() const; /** * \brief Enables a capability @@ -40,7 +38,7 @@ namespace dxvk { private: - std::unordered_set m_caps; + SpirvCodeBuffer m_code; }; diff --git a/src/dxbc/dxbc_annotation.cpp b/src/spirv/gen/spirv_gen_constant.cpp similarity index 100% rename from src/dxbc/dxbc_annotation.cpp rename to src/spirv/gen/spirv_gen_constant.cpp diff --git a/src/dxbc/dxbc_annotation.h b/src/spirv/gen/spirv_gen_constant.h similarity index 100% rename from src/dxbc/dxbc_annotation.h rename to src/spirv/gen/spirv_gen_constant.h diff --git a/src/spirv/gen/spirv_gen_debuginfo.cpp b/src/spirv/gen/spirv_gen_debuginfo.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/spirv/gen/spirv_gen_debuginfo.h b/src/spirv/gen/spirv_gen_debuginfo.h new file mode 100644 index 00000000..e69de29b diff --git a/src/spirv/gen/spirv_gen_decoration.cpp b/src/spirv/gen/spirv_gen_decoration.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/spirv/gen/spirv_gen_decoration.h b/src/spirv/gen/spirv_gen_decoration.h new file mode 100644 index 00000000..e69de29b diff --git a/src/dxbc/dxbc_entrypoint.cpp b/src/spirv/gen/spirv_gen_entrypoint.cpp similarity index 80% rename from src/dxbc/dxbc_entrypoint.cpp rename to src/spirv/gen/spirv_gen_entrypoint.cpp index 5f1b6a09..fc99d837 100644 --- a/src/dxbc/dxbc_entrypoint.cpp +++ b/src/spirv/gen/spirv_gen_entrypoint.cpp @@ -1,13 +1,13 @@ -#include "dxbc_entrypoint.h" +#include "spirv_gen_entrypoint.h" namespace dxvk { - DxbcEntryPoint:: DxbcEntryPoint() { } - DxbcEntryPoint::~DxbcEntryPoint() { } + SpirvEntryPoint:: SpirvEntryPoint() { } + SpirvEntryPoint::~SpirvEntryPoint() { } - DxvkSpirvCodeBuffer DxbcEntryPoint::code() const { - DxvkSpirvCodeBuffer code; + SpirvCodeBuffer SpirvEntryPoint::code() const { + SpirvCodeBuffer code; code.append(m_memoryModel); code.append(m_entryPoints); code.append(m_execModeInfo); @@ -15,7 +15,7 @@ namespace dxvk { } - void DxbcEntryPoint::setMemoryModel( + void SpirvEntryPoint::setMemoryModel( spv::AddressingModel addressModel, spv::MemoryModel memoryModel) { m_memoryModel.putIns (spv::OpMemoryModel, 3); @@ -24,7 +24,7 @@ namespace dxvk { } - void DxbcEntryPoint::addEntryPoint( + void SpirvEntryPoint::addEntryPoint( uint32_t functionId, spv::ExecutionModel execModel, const char* name, @@ -40,7 +40,7 @@ namespace dxvk { } - void DxbcEntryPoint::setLocalSize( + void SpirvEntryPoint::setLocalSize( uint32_t functionId, uint32_t x, uint32_t y, diff --git a/src/dxbc/dxbc_entrypoint.h b/src/spirv/gen/spirv_gen_entrypoint.h similarity index 89% rename from src/dxbc/dxbc_entrypoint.h rename to src/spirv/gen/spirv_gen_entrypoint.h index be75704e..5563acd2 100644 --- a/src/dxbc/dxbc_entrypoint.h +++ b/src/spirv/gen/spirv_gen_entrypoint.h @@ -1,6 +1,6 @@ #pragma once -#include "dxbc_include.h" +#include "../spirv_code_buffer.h" namespace dxvk { @@ -11,18 +11,18 @@ namespace dxvk { * point of the generated shader module, * including execution mode info. */ - class DxbcEntryPoint { + class SpirvEntryPoint { public: - DxbcEntryPoint(); - ~DxbcEntryPoint(); + SpirvEntryPoint(); + ~SpirvEntryPoint(); /** * \brief Generates SPIR-V code * \returns SPIR-V code buffer */ - DxvkSpirvCodeBuffer code() const; + SpirvCodeBuffer code() const; /** * \brief Sets memory model @@ -73,9 +73,9 @@ namespace dxvk { private: - DxvkSpirvCodeBuffer m_memoryModel; - DxvkSpirvCodeBuffer m_entryPoints; - DxvkSpirvCodeBuffer m_execModeInfo; + SpirvCodeBuffer m_memoryModel; + SpirvCodeBuffer m_entryPoints; + SpirvCodeBuffer m_execModeInfo; }; diff --git a/src/spirv/spirv_id_counter.h b/src/spirv/gen/spirv_gen_id.h similarity index 87% rename from src/spirv/spirv_id_counter.h rename to src/spirv/gen/spirv_gen_id.h index 19d0eb2d..f0f108b6 100644 --- a/src/spirv/spirv_id_counter.h +++ b/src/spirv/gen/spirv_gen_id.h @@ -1,6 +1,6 @@ #pragma once -#include "spirv_include.h" +#include "../spirv_include.h" namespace dxvk { @@ -11,7 +11,7 @@ namespace dxvk { * to be used to allocate unique IDs during code * generation. */ - class DxvkSpirvIdCounter { + class SpirvIdCounter { public: diff --git a/src/dxbc/dxbc_typeinfo.cpp b/src/spirv/gen/spirv_gen_typeinfo.cpp similarity index 71% rename from src/dxbc/dxbc_typeinfo.cpp rename to src/spirv/gen/spirv_gen_typeinfo.cpp index 8efb7522..6335e9a8 100644 --- a/src/dxbc/dxbc_typeinfo.cpp +++ b/src/spirv/gen/spirv_gen_typeinfo.cpp @@ -1,32 +1,32 @@ -#include "dxbc_typeinfo.h" +#include + +#include "spirv_gen_typeinfo.h" namespace dxvk { - DxbcTypeInfo:: DxbcTypeInfo() { } - DxbcTypeInfo::~DxbcTypeInfo() { } + SpirvTypeInfo:: SpirvTypeInfo() { } + SpirvTypeInfo::~SpirvTypeInfo() { } - DxvkSpirvCodeBuffer DxbcTypeInfo::code() const { + SpirvCodeBuffer SpirvTypeInfo::code() const { return m_code; } - uint32_t DxbcTypeInfo::typeVoid( - DxvkSpirvIdCounter& ids) { + uint32_t SpirvTypeInfo::typeVoid(SpirvIdCounter& ids) { return this->getTypeId(ids, spv::OpTypeVoid, 0, nullptr); } - uint32_t DxbcTypeInfo::typeBool( - DxvkSpirvIdCounter& ids) { + uint32_t SpirvTypeInfo::typeBool(SpirvIdCounter& ids) { return this->getTypeId(ids, spv::OpTypeBool, 0, nullptr); } - uint32_t DxbcTypeInfo::typeInt( - DxvkSpirvIdCounter& ids, + uint32_t SpirvTypeInfo::typeInt( + SpirvIdCounter& ids, uint32_t width, uint32_t isSigned) { std::array args = {{ width, isSigned }}; @@ -35,16 +35,16 @@ namespace dxvk { } - uint32_t DxbcTypeInfo::typeFloat( - DxvkSpirvIdCounter& ids, + uint32_t SpirvTypeInfo::typeFloat( + SpirvIdCounter& ids, uint32_t width) { return this->getTypeId(ids, spv::OpTypeFloat, 1, &width); } - uint32_t DxbcTypeInfo::typeVector( - DxvkSpirvIdCounter& ids, + uint32_t SpirvTypeInfo::typeVector( + SpirvIdCounter& ids, uint32_t componentType, uint32_t componentCount) { std::array args = {{ componentType, componentCount }}; @@ -53,8 +53,8 @@ namespace dxvk { } - uint32_t DxbcTypeInfo::typeMatrix( - DxvkSpirvIdCounter& ids, + uint32_t SpirvTypeInfo::typeMatrix( + SpirvIdCounter& ids, uint32_t colType, uint32_t colCount) { std::array args = {{ colType, colCount }}; @@ -63,8 +63,8 @@ namespace dxvk { } - uint32_t DxbcTypeInfo::typeArray( - DxvkSpirvIdCounter& ids, + uint32_t SpirvTypeInfo::typeArray( + SpirvIdCounter& ids, uint32_t elementType, uint32_t elementCount) { std::array args = {{ elementType, elementCount }}; @@ -73,16 +73,16 @@ namespace dxvk { } - uint32_t DxbcTypeInfo::typeRuntimeArray( - DxvkSpirvIdCounter& ids, + uint32_t SpirvTypeInfo::typeRuntimeArray( + SpirvIdCounter& ids, uint32_t elementType) { return this->getTypeId(ids, spv::OpTypeRuntimeArray, 1, &elementType); } - uint32_t DxbcTypeInfo::typePointer( - DxvkSpirvIdCounter& ids, + uint32_t SpirvTypeInfo::typePointer( + SpirvIdCounter& ids, spv::StorageClass storageClass, uint32_t type) { std::array args = {{ storageClass, type }}; @@ -91,8 +91,8 @@ namespace dxvk { } - uint32_t DxbcTypeInfo::typeFunction( - DxvkSpirvIdCounter& ids, + uint32_t SpirvTypeInfo::typeFunction( + SpirvIdCounter& ids, uint32_t returnType, uint32_t argCount, const uint32_t* argTypes) { @@ -108,8 +108,8 @@ namespace dxvk { } - uint32_t DxbcTypeInfo::typeStruct( - DxvkSpirvIdCounter& ids, + uint32_t SpirvTypeInfo::typeStruct( + SpirvIdCounter& ids, uint32_t memberCount, const uint32_t* memberTypes) { return this->getTypeId(ids, @@ -119,11 +119,11 @@ namespace dxvk { } - uint32_t DxbcTypeInfo::getTypeId( - DxvkSpirvIdCounter& ids, - spv::Op op, - uint32_t argCount, - const uint32_t* args) { + uint32_t SpirvTypeInfo::getTypeId( + SpirvIdCounter& ids, + spv::Op op, + uint32_t argCount, + const uint32_t* args) { // Since the type info is stored in the code buffer, // we can use the code buffer to look up type IDs as // well. Result IDs are always stored as argument 1. diff --git a/src/dxbc/dxbc_typeinfo.h b/src/spirv/gen/spirv_gen_typeinfo.h similarity index 62% rename from src/dxbc/dxbc_typeinfo.h rename to src/spirv/gen/spirv_gen_typeinfo.h index c4c93316..ae609422 100644 --- a/src/dxbc/dxbc_typeinfo.h +++ b/src/spirv/gen/spirv_gen_typeinfo.h @@ -1,8 +1,8 @@ #pragma once -#include +#include "../spirv_code_buffer.h" -#include "dxbc_include.h" +#include "spirv_gen_id.h" namespace dxvk { @@ -12,74 +12,74 @@ namespace dxvk { * Stores SPIR-V type definition so that * each type will only be declared once. */ - class DxbcTypeInfo { + class SpirvTypeInfo { public: - DxbcTypeInfo(); - ~DxbcTypeInfo(); + SpirvTypeInfo(); + ~SpirvTypeInfo(); - DxvkSpirvCodeBuffer code() const; + SpirvCodeBuffer code() const; uint32_t typeVoid( - DxvkSpirvIdCounter& ids); + SpirvIdCounter& ids); uint32_t typeBool( - DxvkSpirvIdCounter& ids); + SpirvIdCounter& ids); uint32_t typeInt( - DxvkSpirvIdCounter& ids, + SpirvIdCounter& ids, uint32_t width, uint32_t isSigned); uint32_t typeFloat( - DxvkSpirvIdCounter& ids, + SpirvIdCounter& ids, uint32_t width); uint32_t typeVector( - DxvkSpirvIdCounter& ids, + SpirvIdCounter& ids, uint32_t componentType, uint32_t componentCount); uint32_t typeMatrix( - DxvkSpirvIdCounter& ids, + SpirvIdCounter& ids, uint32_t colType, uint32_t colCount); uint32_t typeArray( - DxvkSpirvIdCounter& ids, + SpirvIdCounter& ids, uint32_t elementType, uint32_t elementCount); uint32_t typeRuntimeArray( - DxvkSpirvIdCounter& ids, + SpirvIdCounter& ids, uint32_t elementType); uint32_t typePointer( - DxvkSpirvIdCounter& ids, + SpirvIdCounter& ids, spv::StorageClass storageClass, uint32_t type); uint32_t typeFunction( - DxvkSpirvIdCounter& ids, + SpirvIdCounter& ids, uint32_t returnType, uint32_t argCount, const uint32_t* argTypes); uint32_t typeStruct( - DxvkSpirvIdCounter& ids, + SpirvIdCounter& ids, uint32_t memberCount, const uint32_t* memberTypes); private: - DxvkSpirvCodeBuffer m_code; + SpirvCodeBuffer m_code; uint32_t getTypeId( - DxvkSpirvIdCounter& ids, - spv::Op op, - uint32_t argCount, - const uint32_t* args); + SpirvIdCounter& ids, + spv::Op op, + uint32_t argCount, + const uint32_t* args); }; diff --git a/src/spirv/gen/spirv_gen_variable.cpp b/src/spirv/gen/spirv_gen_variable.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/spirv/gen/spirv_gen_variable.h b/src/spirv/gen/spirv_gen_variable.h new file mode 100644 index 00000000..e69de29b diff --git a/src/spirv/meson.build b/src/spirv/meson.build index 252e836f..c31b799d 100644 --- a/src/spirv/meson.build +++ b/src/spirv/meson.build @@ -1,5 +1,13 @@ spirv_src = files([ - 'spirv_code_buffer.cpp' + 'spirv_code_buffer.cpp', + + 'gen/spirv_gen_capability.cpp', + 'gen/spirv_gen_constant.cpp', + 'gen/spirv_gen_debuginfo.cpp', + 'gen/spirv_gen_decoration.cpp', + 'gen/spirv_gen_entrypoint.cpp', + 'gen/spirv_gen_typeinfo.cpp', + 'gen/spirv_gen_variable.cpp', ]) spirv_lib = static_library('spirv', spirv_src, diff --git a/src/spirv/spirv_code_buffer.cpp b/src/spirv/spirv_code_buffer.cpp index 8936ff0e..4baa2b28 100644 --- a/src/spirv/spirv_code_buffer.cpp +++ b/src/spirv/spirv_code_buffer.cpp @@ -5,11 +5,11 @@ namespace dxvk { - DxvkSpirvCodeBuffer:: DxvkSpirvCodeBuffer() { } - DxvkSpirvCodeBuffer::~DxvkSpirvCodeBuffer() { } + SpirvCodeBuffer:: SpirvCodeBuffer() { } + SpirvCodeBuffer::~SpirvCodeBuffer() { } - DxvkSpirvCodeBuffer::DxvkSpirvCodeBuffer(std::istream&& stream) { + SpirvCodeBuffer::SpirvCodeBuffer(std::istream&& stream) { stream.ignore(std::numeric_limits::max()); std::streamsize length = stream.gcount(); stream.clear(); @@ -25,7 +25,7 @@ namespace dxvk { } - void DxvkSpirvCodeBuffer::append(const DxvkSpirvCodeBuffer& other) { + void SpirvCodeBuffer::append(const SpirvCodeBuffer& other) { if (other.size() != 0) { const size_t size = m_code.size(); m_code.resize(size + other.m_code.size()); @@ -38,30 +38,30 @@ namespace dxvk { } - void DxvkSpirvCodeBuffer::putWord(uint32_t word) { + void SpirvCodeBuffer::putWord(uint32_t word) { m_code.push_back(word); } - void DxvkSpirvCodeBuffer::putIns(spv::Op opCode, uint16_t wordCount) { + void SpirvCodeBuffer::putIns(spv::Op opCode, uint16_t wordCount) { this->putWord( (static_cast(opCode) << 0) | (static_cast(wordCount) << 16)); } - void DxvkSpirvCodeBuffer::putInt32(uint32_t word) { + void SpirvCodeBuffer::putInt32(uint32_t word) { this->putWord(word); } - void DxvkSpirvCodeBuffer::putInt64(uint64_t value) { + void SpirvCodeBuffer::putInt64(uint64_t value) { this->putWord(value >> 0); this->putWord(value >> 32); } - void DxvkSpirvCodeBuffer::putFloat32(float value) { + void SpirvCodeBuffer::putFloat32(float value) { uint32_t tmp; static_assert(sizeof(tmp) == sizeof(value)); std::memcpy(&tmp, &value, sizeof(value)); @@ -69,7 +69,7 @@ namespace dxvk { } - void DxvkSpirvCodeBuffer::putFloat64(double value) { + void SpirvCodeBuffer::putFloat64(double value) { uint64_t tmp; static_assert(sizeof(tmp) == sizeof(value)); std::memcpy(&tmp, &value, sizeof(value)); @@ -77,7 +77,7 @@ namespace dxvk { } - void DxvkSpirvCodeBuffer::putStr(const char* str) { + void SpirvCodeBuffer::putStr(const char* str) { uint32_t word = 0; uint32_t nbit = 0; @@ -96,7 +96,7 @@ namespace dxvk { } - void DxvkSpirvCodeBuffer::putHeader(uint32_t boundIds) { + void SpirvCodeBuffer::putHeader(uint32_t boundIds) { this->putWord(spv::MagicNumber); this->putWord(spv::Version); this->putWord(0); // Generator @@ -105,13 +105,13 @@ namespace dxvk { } - uint32_t DxvkSpirvCodeBuffer::strLen(const char* str) { + uint32_t SpirvCodeBuffer::strLen(const char* str) { // Null-termination plus padding return (std::strlen(str) + 4) / 4; } - void DxvkSpirvCodeBuffer::store(std::ostream&& stream) const { + void SpirvCodeBuffer::store(std::ostream&& stream) const { stream.write( reinterpret_cast(m_code.data()), sizeof(uint32_t) * m_code.size()); diff --git a/src/spirv/spirv_code_buffer.h b/src/spirv/spirv_code_buffer.h index c0a6f98d..1e6e0368 100644 --- a/src/spirv/spirv_code_buffer.h +++ b/src/spirv/spirv_code_buffer.h @@ -16,13 +16,13 @@ namespace dxvk { * Stores arbitrary SPIR-V instructions in a * format that can be read by Vulkan drivers. */ - class DxvkSpirvCodeBuffer { + class SpirvCodeBuffer { public: - DxvkSpirvCodeBuffer(); - DxvkSpirvCodeBuffer(std::istream&& stream); - ~DxvkSpirvCodeBuffer(); + SpirvCodeBuffer(); + SpirvCodeBuffer(std::istream&& stream); + ~SpirvCodeBuffer(); /** * \brief Code data @@ -47,8 +47,8 @@ namespace dxvk { * block. The header, if any, will be skipped over. * \returns Instruction iterator */ - DxvkSpirvInstructionIterator begin() const { - return DxvkSpirvInstructionIterator(m_code.data(), m_code.size()); + SpirvInstructionIterator begin() const { + return SpirvInstructionIterator(m_code.data(), m_code.size()); } /** @@ -57,8 +57,8 @@ namespace dxvk { * Points to the end of the instruction block. * \returns Instruction iterator */ - DxvkSpirvInstructionIterator end() const { - return DxvkSpirvInstructionIterator(nullptr, 0); + SpirvInstructionIterator end() const { + return SpirvInstructionIterator(nullptr, 0); } /** @@ -69,7 +69,7 @@ namespace dxvk { * code when doing so in advance is impossible. * \param [in] other Code buffer to append */ - void append(const DxvkSpirvCodeBuffer& other); + void append(const SpirvCodeBuffer& other); /** * \brief Appends an 32-bit word to the buffer diff --git a/src/spirv/spirv_instruction.h b/src/spirv/spirv_instruction.h index 17e5d01e..8ee75694 100644 --- a/src/spirv/spirv_instruction.h +++ b/src/spirv/spirv_instruction.h @@ -13,12 +13,12 @@ namespace dxvk { * access to the op code, instruction length and * instruction arguments. */ - class DxvkSpirvInstruction { + class SpirvInstruction { public: - DxvkSpirvInstruction() { } - DxvkSpirvInstruction( + SpirvInstruction() { } + SpirvInstruction( const uint32_t* code, uint32_t size) : m_code(code), m_size(size) { } @@ -67,32 +67,32 @@ namespace dxvk { * Convenient iterator that can be used * to process raw SPIR-V shader code. */ - class DxvkSpirvInstructionIterator { + class SpirvInstructionIterator { public: - DxvkSpirvInstructionIterator() { } - DxvkSpirvInstructionIterator(const uint32_t* code, uint32_t size) + SpirvInstructionIterator() { } + SpirvInstructionIterator(const uint32_t* code, uint32_t size) : m_code(size != 0 ? code : nullptr), m_size(size) { if ((size >= 5) && (m_code[0] == spv::MagicNumber)) this->advance(5); } - DxvkSpirvInstructionIterator& operator ++ () { - this->advance(DxvkSpirvInstruction(m_code, m_size).length()); + SpirvInstructionIterator& operator ++ () { + this->advance(SpirvInstruction(m_code, m_size).length()); return *this; } - DxvkSpirvInstruction operator * () const { - return DxvkSpirvInstruction(m_code, m_size); + SpirvInstruction operator * () const { + return SpirvInstruction(m_code, m_size); } - bool operator == (const DxvkSpirvInstructionIterator& other) const { + bool operator == (const SpirvInstructionIterator& other) const { return this->m_code == other.m_code && this->m_size == other.m_size; } - bool operator != (const DxvkSpirvInstructionIterator& other) const { + bool operator != (const SpirvInstructionIterator& other) const { return this->m_code != other.m_code && this->m_size != other.m_size; } diff --git a/tests/dxvk/test_dxvk_triangle.cpp b/tests/dxvk/test_dxvk_triangle.cpp index 107e6fd6..d0d9cca9 100644 --- a/tests/dxvk/test_dxvk_triangle.cpp +++ b/tests/dxvk/test_dxvk_triangle.cpp @@ -54,7 +54,7 @@ public: computeBufferSlot.type = DxvkResourceType::StorageBuffer; computeBufferSlot.slot = 0; - DxvkSpirvCodeBuffer code(std::ifstream("comp.spv", std::ios::binary)); + SpirvCodeBuffer code(std::ifstream("comp.spv", std::ios::binary)); code.store(std::ofstream("comp.2.spv", std::ios::binary)); m_compShader = new DxvkShader(