From 883ae9f39d83279036040bdfde006a4a132689ad Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sat, 14 Oct 2017 23:52:47 +0200 Subject: [PATCH] [dxvk] Added pipeline manager stub --- src/dxvk/dxvk_compute.cpp | 92 +++++++++++++++++++++- src/dxvk/dxvk_compute.h | 27 ++++++- src/dxvk/dxvk_context.cpp | 6 +- src/dxvk/dxvk_context.h | 5 +- src/dxvk/dxvk_deferred.h | 11 ++- src/dxvk/dxvk_device.cpp | 14 +++- src/dxvk/dxvk_device.h | 11 ++- src/dxvk/dxvk_graphics.cpp | 0 src/dxvk/dxvk_graphics.h | 36 +++++++++ src/dxvk/dxvk_pipemgr.cpp | 26 ++++++ src/dxvk/dxvk_pipemgr.h | 58 ++++++++++++++ src/dxvk/dxvk_shader.cpp | 69 ++++++++++------ src/dxvk/dxvk_shader.h | 96 +++++++++++++---------- src/dxvk/meson.build | 3 +- src/dxvk/spirv/dxvk_spirv_code_buffer.cpp | 28 +++---- src/dxvk/spirv/dxvk_spirv_code_buffer.h | 16 ++-- 16 files changed, 387 insertions(+), 111 deletions(-) create mode 100644 src/dxvk/dxvk_graphics.cpp create mode 100644 src/dxvk/dxvk_graphics.h create mode 100644 src/dxvk/dxvk_pipemgr.cpp create mode 100644 src/dxvk/dxvk_pipemgr.h diff --git a/src/dxvk/dxvk_compute.cpp b/src/dxvk/dxvk_compute.cpp index a51f7ed9..c9808b8f 100644 --- a/src/dxvk/dxvk_compute.cpp +++ b/src/dxvk/dxvk_compute.cpp @@ -3,15 +3,99 @@ namespace dxvk { DxvkComputePipeline::DxvkComputePipeline( - const Rc& vkd) + const Rc& vkd, + const Rc& shader) : m_vkd(vkd) { - // TODO implement + + std::vector bindings; + + for (uint32_t i = 0; i < shader->slotCount(); i++) + bindings.push_back(shader->slotBinding(0, i)); + + VkDescriptorSetLayoutCreateInfo dlayout; + dlayout.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; + dlayout.pNext = nullptr; + dlayout.flags = 0; + dlayout.bindingCount = bindings.size(); + dlayout.pBindings = bindings.data(); + + if (m_vkd->vkCreateDescriptorSetLayout(m_vkd->device(), + &dlayout, nullptr, &m_descriptorSetLayout) != VK_SUCCESS) + throw DxvkError("DxvkComputePipeline::DxvkComputePipeline: Failed to create descriptor set layout"); + + VkPipelineLayoutCreateInfo playout; + playout.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; + playout.pNext = nullptr; + playout.flags = 0; + playout.setLayoutCount = 1; + playout.pSetLayouts = &m_descriptorSetLayout; + playout.pushConstantRangeCount = 0; + playout.pPushConstantRanges = nullptr; + + if (m_vkd->vkCreatePipelineLayout(m_vkd->device(), + &playout, nullptr, &m_pipelineLayout) != VK_SUCCESS) { + this->destroyObjects(); + throw DxvkError("DxvkComputePipeline::DxvkComputePipeline: Failed to create pipeline layout"); + } + + DxvkSpirvCodeBuffer code = shader->code(0); + + VkShaderModuleCreateInfo minfo; + minfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; + minfo.pNext = nullptr; + minfo.flags = 0; + minfo.codeSize = code.size(); + minfo.pCode = code.data(); + + if (m_vkd->vkCreateShaderModule(m_vkd->device(), + &minfo, nullptr, &m_module) != VK_SUCCESS) { + this->destroyObjects(); + throw DxvkError("DxvkComputePipeline::DxvkComputePipeline: Failed to create shader module"); + } + + VkPipelineShaderStageCreateInfo sinfo; + sinfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; + sinfo.pNext = nullptr; + sinfo.flags = 0; + sinfo.stage = VK_SHADER_STAGE_COMPUTE_BIT; + sinfo.module = m_module; + sinfo.pName = "main"; + sinfo.pSpecializationInfo = nullptr; + + VkComputePipelineCreateInfo info; + info.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO; + info.pNext = nullptr; + info.flags = 0; + info.stage = sinfo; + info.layout = m_pipelineLayout; + info.basePipelineHandle = VK_NULL_HANDLE; + info.basePipelineIndex = 0; + + if (m_vkd->vkCreateComputePipelines(m_vkd->device(), + VK_NULL_HANDLE, 1, &info, nullptr, &m_pipeline) != VK_SUCCESS) { + this->destroyObjects(); + throw DxvkError("DxvkComputePipeline::DxvkComputePipeline: Failed to compipe pipeline"); + } } DxvkComputePipeline::~DxvkComputePipeline() { - m_vkd->vkDestroyPipeline( - m_vkd->device(), m_pipeline, nullptr); + this->destroyObjects(); + } + + + void DxvkComputePipeline::destroyObjects() { + if (m_pipeline != VK_NULL_HANDLE) + m_vkd->vkDestroyPipeline(m_vkd->device(), m_pipeline, nullptr); + + if (m_module != VK_NULL_HANDLE) + m_vkd->vkDestroyShaderModule(m_vkd->device(), m_module, nullptr); + + if (m_pipelineLayout != VK_NULL_HANDLE) + m_vkd->vkDestroyPipelineLayout(m_vkd->device(), m_pipelineLayout, nullptr); + + if (m_descriptorSetLayout != VK_NULL_HANDLE) + m_vkd->vkDestroyDescriptorSetLayout(m_vkd->device(), m_descriptorSetLayout, nullptr); } } \ No newline at end of file diff --git a/src/dxvk/dxvk_compute.h b/src/dxvk/dxvk_compute.h index ebaf3ab1..4e968430 100644 --- a/src/dxvk/dxvk_compute.h +++ b/src/dxvk/dxvk_compute.h @@ -1,6 +1,7 @@ #pragma once #include "dxvk_shader.h" +#include "dxvk_resource.h" namespace dxvk { @@ -12,13 +13,26 @@ namespace dxvk { * pipelines do not need to be recompiled against any sort * of pipeline state. */ - class DxvkComputePipeline : public RcObject { + class DxvkComputePipeline : public DxvkResource { public: - DxvkComputePipeline(const Rc& vkd); + DxvkComputePipeline( + const Rc& vkd, + const Rc& shader); ~DxvkComputePipeline(); + /** + * \brief Descriptor set layout + * + * The descriptor set layout for this pipeline. + * Use this to allocate new descriptor sets. + * \returns The descriptor set layout + */ + VkDescriptorSetLayout descriptorSetLayout() const { + return m_descriptorSetLayout; + } + /** * \brief Pipeline handle * \returns Pipeline handle @@ -29,8 +43,13 @@ namespace dxvk { private: - Rc m_vkd; - VkPipeline m_pipeline; + Rc m_vkd; + VkDescriptorSetLayout m_descriptorSetLayout = VK_NULL_HANDLE; + VkPipelineLayout m_pipelineLayout = VK_NULL_HANDLE; + VkShaderModule m_module = VK_NULL_HANDLE; + VkPipeline m_pipeline = VK_NULL_HANDLE; + + void destroyObjects(); }; diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 0dc6511a..35229dd2 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -1,10 +1,12 @@ +#include "dxvk_device.h" #include "dxvk_context.h" #include "dxvk_main.h" namespace dxvk { - DxvkContext::DxvkContext() { - TRACE(this); + DxvkContext::DxvkContext(const Rc& device) + : m_device(device) { + TRACE(this, device); } diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index 208f7523..be27bce9 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -17,7 +17,8 @@ namespace dxvk { public: - DxvkContext(); + DxvkContext( + const Rc& device); ~DxvkContext(); /** @@ -125,6 +126,8 @@ namespace dxvk { private: + const Rc m_device; + Rc m_cmd; DxvkContextState m_state; diff --git a/src/dxvk/dxvk_deferred.h b/src/dxvk/dxvk_deferred.h index 76633cfe..f3dd5505 100644 --- a/src/dxvk/dxvk_deferred.h +++ b/src/dxvk/dxvk_deferred.h @@ -8,13 +8,12 @@ namespace dxvk { /** - * \brief DXVK command list + * \brief DXVK deferred command list * - * Stores a command buffer that a context can use to record Vulkan - * commands. The command list shall also reference the resources - * used by the recorded commands for automatic lifetime tracking. - * When the command list has completed execution, resources that - * are no longer used may get destroyed. + * Buffers Vulkan commands so that they can be recorded + * into an actual Vulkan command buffer later. This is + * used to implement D3D11 Deferred Contexts, which do + * not map particularly well to Vulkan's command buffers. */ class DxvkDeferredCommands : public DxvkRecorder { diff --git a/src/dxvk/dxvk_device.cpp b/src/dxvk/dxvk_device.cpp index 9a4c68dd..0f43266f 100644 --- a/src/dxvk/dxvk_device.cpp +++ b/src/dxvk/dxvk_device.cpp @@ -35,7 +35,7 @@ namespace dxvk { Rc DxvkDevice::createContext() { - return new DxvkContext(); + return new DxvkContext(this); } @@ -66,6 +66,18 @@ namespace dxvk { } + Rc DxvkDevice::createShader( + VkShaderStageFlagBits stage, + DxvkSpirvCodeBuffer&& code, + uint32_t numResourceSlots, + const DxvkResourceSlot* resourceSlots) { + return new DxvkShader(stage, + std::move(code), + numResourceSlots, + resourceSlots); + } + + Rc DxvkDevice::createSwapchain( const Rc& surface, const DxvkSwapchainProperties& properties) { diff --git a/src/dxvk/dxvk_device.h b/src/dxvk/dxvk_device.h index 93413925..66c9dd37 100644 --- a/src/dxvk/dxvk_device.h +++ b/src/dxvk/dxvk_device.h @@ -2,6 +2,7 @@ #include "dxvk_adapter.h" #include "dxvk_buffer.h" +#include "dxvk_compute.h" #include "dxvk_context.h" #include "dxvk_framebuffer.h" #include "dxvk_memory.h" @@ -115,13 +116,17 @@ namespace dxvk { /** * \brief Creates a shader module * - * \param [in] iface Shader interface + * \param [in] stage Shader stage * \param [in] code SPIR-V code + * \param [in] numResourceSlots Resource slot count + * \param [in] resourceSlots Resource slot array * \returns Shader module */ Rc createShader( - const DxvkShaderInterface& iface, - const SpirvCodeBuffer& code); + VkShaderStageFlagBits stage, + DxvkSpirvCodeBuffer&& code, + uint32_t numResourceSlots, + const DxvkResourceSlot* resourceSlots); /** * \brief Creates a swap chain diff --git a/src/dxvk/dxvk_graphics.cpp b/src/dxvk/dxvk_graphics.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/dxvk/dxvk_graphics.h b/src/dxvk/dxvk_graphics.h new file mode 100644 index 00000000..8de76016 --- /dev/null +++ b/src/dxvk/dxvk_graphics.h @@ -0,0 +1,36 @@ +#pragma once + +#include + +#include "dxvk_shader.h" +#include "dxvk_resource.h" + +namespace dxvk { + + /** + * \brief Graphics pipeline + * + * Stores the pipeline layout as well as methods to + * recompile the graphics pipeline against a given + * pipeline state vector. + */ + class DxvkGraphicsPipeline : public DxvkResource { + + public: + + DxvkGraphicsPipeline( + const Rc& vkd, + const Rc& vs, + const Rc& tcs, + const Rc& tes, + const Rc& gs, + const Rc& fs); + ~DxvkGraphicsPipeline(); + + private: + + std::mutex m_mutex; + + }; + +} \ No newline at end of file diff --git a/src/dxvk/dxvk_pipemgr.cpp b/src/dxvk/dxvk_pipemgr.cpp new file mode 100644 index 00000000..7457c933 --- /dev/null +++ b/src/dxvk/dxvk_pipemgr.cpp @@ -0,0 +1,26 @@ +#include "dxvk_pipemgr.h" + +namespace dxvk { + + DxvkPipelineManager:: DxvkPipelineManager() { } + DxvkPipelineManager::~DxvkPipelineManager() { } + + + Rc DxvkPipelineManager::getComputePipeline( + const Rc& cs) { + + + + } + + + Rc DxvkPipelineManager::getGraphicsPipeline( + const Rc& vs, + const Rc& tcs, + const Rc& tes, + const Rc& gs, + const Rc& fs) { + + } + +} \ No newline at end of file diff --git a/src/dxvk/dxvk_pipemgr.h b/src/dxvk/dxvk_pipemgr.h new file mode 100644 index 00000000..dd14babb --- /dev/null +++ b/src/dxvk/dxvk_pipemgr.h @@ -0,0 +1,58 @@ +#pragma once + +#include "dxvk_compute.h" +#include "dxvk_graphics.h" + +namespace dxvk { + + /** + * \brief Pipeline manager + * + * Creates and manages pipeline objects + * for various combinations of shaders. + */ + class DxvkPipelineManager : public RcObject { + + public: + + DxvkPipelineManager(); + ~DxvkPipelineManager(); + + /** + * \brief Retrieves compute pipeline + * + * Retrieves a compute pipeline object for the given + * shader. If no such pipeline object exists, a new + * one will be created. + * \param [in] cs Compute shader + */ + Rc getComputePipeline( + const Rc& cs); + + /** + * \brief Retrieves graphics pipeline + * + * Retrieves a graphics pipeline object for the given + * combination of shaders. If no such pipeline object + * exists, a new one will be created. + * \param [in] vs Vertex shader + * \param [in] tcs Tessellation control shader + * \param [in] tes Tessellation evaluation shader + * \param [in] gs Geometry shader + * \param [in] fs Fragment shader + * \returns Graphics pipeline + */ + Rc getGraphicsPipeline( + const Rc& vs, + const Rc& tcs, + const Rc& tes, + const Rc& gs, + const Rc& fs); + + private: + + std::mutex m_mutex; + + }; + +} \ No newline at end of file diff --git a/src/dxvk/dxvk_shader.cpp b/src/dxvk/dxvk_shader.cpp index 3d4173a3..3d344535 100644 --- a/src/dxvk/dxvk_shader.cpp +++ b/src/dxvk/dxvk_shader.cpp @@ -2,39 +2,56 @@ namespace dxvk { - DxvkShaderInterface:: DxvkShaderInterface() { } - DxvkShaderInterface::~DxvkShaderInterface() { } - - void DxvkShaderInterface::enableResourceSlot( - const DxvkResourceSlot& slot) { - m_slots.push_back(slot); - } - - DxvkShader::DxvkShader( - const Rc& vkd, - const DxvkShaderInterface& iface, - const SpirvCodeBuffer& code) - : m_vkd(vkd), m_iface(iface) { - TRACE(this); + VkShaderStageFlagBits stage, + DxvkSpirvCodeBuffer&& code, + uint32_t numResourceSlots, + const DxvkResourceSlot* resourceSlots) + : m_stage (stage), + m_code (std::move(code)) { + TRACE(this, stage, numResourceSlots); - VkShaderModuleCreateInfo info; - info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; - info.pNext = nullptr; - info.flags = 0; - info.codeSize = code.size(); - info.pCode = code.code(); - - if (m_vkd->vkCreateShaderModule(m_vkd->device(), - &info, nullptr, &m_shader) != VK_SUCCESS) - throw DxvkError("DxvkShader::DxvkShader: Failed to create shader"); + for (uint32_t i = 0; i < numResourceSlots; i++) + m_slots.push_back(resourceSlots[i]); } DxvkShader::~DxvkShader() { TRACE(this); - m_vkd->vkDestroyShaderModule( - m_vkd->device(), m_shader, nullptr); + } + + + DxvkSpirvCodeBuffer DxvkShader::code( + uint32_t bindingOffset) const { + // TODO implement properly + if (bindingOffset != 0) + Logger::warn("DxvkShader::code: bindingOffset != 0 not yet supported"); + return m_code; + } + + + uint32_t DxvkShader::slotCount() const { + return m_slots.size(); + } + + + DxvkResourceSlot DxvkShader::slot(uint32_t slotId) const { + return m_slots.at(slotId); + } + + + VkDescriptorSetLayoutBinding DxvkShader::slotBinding( + uint32_t slotId, + uint32_t bindingOffset) const { + auto dtype = static_cast(m_slots.at(slotId).type); + + VkDescriptorSetLayoutBinding info; + info.binding = bindingOffset + slotId; + info.descriptorType = dtype; + info.descriptorCount = 1; + info.stageFlags = m_stage; + info.pImmutableSamplers = nullptr; + return info; } } \ No newline at end of file diff --git a/src/dxvk/dxvk_shader.h b/src/dxvk/dxvk_shader.h index 24bd665d..cebea04b 100644 --- a/src/dxvk/dxvk_shader.h +++ b/src/dxvk/dxvk_shader.h @@ -15,10 +15,11 @@ namespace dxvk { * that can be accessed by shaders. */ enum class DxvkResourceType : uint32_t { - UniformBuffer = 0x00, - ImageSampler = 0x01, - SampledImage = 0x02, - StorageBuffer = 0x03, + UniformBuffer = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, + ImageSampler = VK_DESCRIPTOR_TYPE_SAMPLER, + SampledImage = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, + StorageBuffer = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, + StorageImage = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, }; @@ -31,32 +32,6 @@ namespace dxvk { }; - /** - * \brief Shader interface - * - * Stores a list of resource bindings in the - * order they are defined in the shader module. - */ - class DxvkShaderInterface { - - public: - - DxvkShaderInterface(); - ~DxvkShaderInterface(); - - auto size() const { return m_slots.size(); } - auto data() const { return m_slots.data(); } - - void enableResourceSlot( - const DxvkResourceSlot& slot); - - private: - - std::vector m_slots; - - }; - - /** * \brief Shader module * @@ -70,24 +45,63 @@ namespace dxvk { public: DxvkShader( - const Rc& vkd, - const DxvkShaderInterface& iface, - const SpirvCodeBuffer& code); + VkShaderStageFlagBits stage, + DxvkSpirvCodeBuffer&& code, + uint32_t numResourceSlots, + const DxvkResourceSlot* resourceSlots); ~DxvkShader(); /** - * \brief Shader module handle - * \returns Shader module handle + * \brief Retrieves shader code + * + * Since the exact binding IDs are not known by the + * time the shader is created, we need to offset them + * by the first binding index reserved for the shader + * stage that this shader belongs to. + * \param [in] bindingOffset First binding ID + * \returns Modified code buffer */ - VkShaderModule handle() const { - return m_shader; - } + DxvkSpirvCodeBuffer code( + uint32_t bindingOffset) const; + + /** + * \brief Number of resource slots + * \returns Number of enabled slots + */ + uint32_t slotCount() const; + + /** + * \brief Retrieves resource slot properties + * + * Resource slots store which resources that are bound + * to a DXVK context are used by the shader. The slot + * ID corresponds to the binding index relative to the + * first binding index within the shader. + * \param [in] slotId Slot index + * \returns The resource slot + */ + DxvkResourceSlot slot( + uint32_t slotId) const; + + /** + * \brief Descriptor set layout binding + * + * Creates Vulkan-compatible binding information for + * a single resource slot. Each resource slot used + * by the shader corresponds to one binding in Vulkan. + * \param [in] slotId Shader binding slot ID + * \param [in] bindingOffset Binding index offset + * \returns Binding info + */ + VkDescriptorSetLayoutBinding slotBinding( + uint32_t slotId, uint32_t bindingOffset) const; private: - Rc m_vkd; - DxvkShaderInterface m_iface; - VkShaderModule m_shader; + VkShaderStageFlagBits m_stage; + DxvkSpirvCodeBuffer m_code; + + std::vector m_slots; }; diff --git a/src/dxvk/meson.build b/src/dxvk/meson.build index 8668300a..01e3fa7e 100644 --- a/src/dxvk/meson.build +++ b/src/dxvk/meson.build @@ -6,12 +6,13 @@ dxvk_src = files([ 'dxvk_deferred.cpp', 'dxvk_device.cpp', 'dxvk_framebuffer.cpp', + 'dxvk_graphics.cpp', 'dxvk_image.cpp', 'dxvk_instance.cpp', - 'dxvk_layout.cpp', 'dxvk_lifetime.cpp', 'dxvk_main.cpp', 'dxvk_memory.cpp', + 'dxvk_pipemgr.cpp', 'dxvk_recorder.cpp', 'dxvk_renderpass.cpp', 'dxvk_resource.cpp', diff --git a/src/dxvk/spirv/dxvk_spirv_code_buffer.cpp b/src/dxvk/spirv/dxvk_spirv_code_buffer.cpp index b898c954..9aeae2b8 100644 --- a/src/dxvk/spirv/dxvk_spirv_code_buffer.cpp +++ b/src/dxvk/spirv/dxvk_spirv_code_buffer.cpp @@ -5,18 +5,18 @@ namespace dxvk { - SpirvCodeBuffer:: SpirvCodeBuffer() { } - SpirvCodeBuffer::~SpirvCodeBuffer() { } + DxvkSpirvCodeBuffer:: DxvkSpirvCodeBuffer() { } + DxvkSpirvCodeBuffer::~DxvkSpirvCodeBuffer() { } - SpirvCodeBuffer::SpirvCodeBuffer( + DxvkSpirvCodeBuffer::DxvkSpirvCodeBuffer( std::basic_istream& stream) : m_code( std::istreambuf_iterator(stream), std::istreambuf_iterator()) { } - void SpirvCodeBuffer::append(const SpirvCodeBuffer& other) { + void DxvkSpirvCodeBuffer::append(const DxvkSpirvCodeBuffer& other) { const size_t size = m_code.size(); m_code.resize(size + other.m_code.size()); @@ -27,30 +27,30 @@ namespace dxvk { } - void SpirvCodeBuffer::putWord(uint32_t word) { + void DxvkSpirvCodeBuffer::putWord(uint32_t word) { m_code.push_back(word); } - void SpirvCodeBuffer::putIns(spv::Op opCode, uint16_t wordCount) { + void DxvkSpirvCodeBuffer::putIns(spv::Op opCode, uint16_t wordCount) { this->putWord( (static_cast(opCode) << 0) | (static_cast(wordCount) << 16)); } - void SpirvCodeBuffer::putInt32(uint32_t word) { + void DxvkSpirvCodeBuffer::putInt32(uint32_t word) { this->putWord(word); } - void SpirvCodeBuffer::putInt64(uint64_t value) { + void DxvkSpirvCodeBuffer::putInt64(uint64_t value) { this->putWord(value >> 0); this->putWord(value >> 32); } - void SpirvCodeBuffer::putFloat32(float value) { + void DxvkSpirvCodeBuffer::putFloat32(float value) { uint32_t tmp; static_assert(sizeof(tmp) == sizeof(value)); std::memcpy(&tmp, &value, sizeof(value)); @@ -58,7 +58,7 @@ namespace dxvk { } - void SpirvCodeBuffer::putFloat64(double value) { + void DxvkSpirvCodeBuffer::putFloat64(double value) { uint64_t tmp; static_assert(sizeof(tmp) == sizeof(value)); std::memcpy(&tmp, &value, sizeof(value)); @@ -66,7 +66,7 @@ namespace dxvk { } - void SpirvCodeBuffer::putStr(const char* str) { + void DxvkSpirvCodeBuffer::putStr(const char* str) { uint32_t word = 0; uint32_t nbit = 0; @@ -85,7 +85,7 @@ namespace dxvk { } - void SpirvCodeBuffer::putHeader(uint32_t boundIds) { + void DxvkSpirvCodeBuffer::putHeader(uint32_t boundIds) { this->putWord(spv::MagicNumber); this->putWord(spv::Version); this->putWord(0); // Generator @@ -94,13 +94,13 @@ namespace dxvk { } - uint32_t SpirvCodeBuffer::strLen(const char* str) { + uint32_t DxvkSpirvCodeBuffer::strLen(const char* str) { // Null-termination plus padding return (std::strlen(str) + 4) / 4; } - void SpirvCodeBuffer::store(std::basic_ostream& stream) const { + void DxvkSpirvCodeBuffer::store(std::basic_ostream& stream) const { stream.write(m_code.data(), m_code.size()); } diff --git a/src/dxvk/spirv/dxvk_spirv_code_buffer.h b/src/dxvk/spirv/dxvk_spirv_code_buffer.h index 7b9236b6..e9907a23 100644 --- a/src/dxvk/spirv/dxvk_spirv_code_buffer.h +++ b/src/dxvk/spirv/dxvk_spirv_code_buffer.h @@ -16,20 +16,20 @@ namespace dxvk { * Stores arbitrary SPIR-V instructions in a * format that can be read by Vulkan drivers. */ - class SpirvCodeBuffer { + class DxvkSpirvCodeBuffer { public: - SpirvCodeBuffer(); - SpirvCodeBuffer( + DxvkSpirvCodeBuffer(); + DxvkSpirvCodeBuffer( std::basic_istream& stream); - ~SpirvCodeBuffer(); + ~DxvkSpirvCodeBuffer(); /** - * \brief Code - * \returns Code + * \brief Code data + * \returns Code data */ - const uint32_t* code() const { + const uint32_t* data() const { return m_code.data(); } @@ -49,7 +49,7 @@ namespace dxvk { * code when doing so in advance is impossible. * \param [in] other Code buffer to append */ - void append(const SpirvCodeBuffer& other); + void append(const DxvkSpirvCodeBuffer& other); /** * \brief Appends an 32-bit word to the buffer