1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00
OpenDX/src/dxvk/dxvk_shader.h

108 lines
2.8 KiB
C
Raw Normal View History

2017-10-11 23:28:06 +02:00
#pragma once
2017-10-14 13:44:38 +02:00
#include <vector>
2017-10-11 23:28:06 +02:00
#include "dxvk_include.h"
#include "./spirv/dxvk_spirv_code_buffer.h"
namespace dxvk {
2017-10-14 13:44:38 +02:00
/**
* \brief Shader resource type
*
* Enumerates the types of resources
* that can be accessed by shaders.
*/
enum class DxvkResourceType : uint32_t {
2017-10-14 23:52:47 +02:00
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,
2017-10-14 13:44:38 +02:00
};
/**
* \brief Resource slot
*/
struct DxvkResourceSlot{
DxvkResourceType type;
uint32_t slot;
};
2017-10-11 23:28:06 +02:00
/**
* \brief Shader module
*
* Manages a Vulkan shader module. This will not
* perform any sort of shader compilation. Instead,
* the context will create pipeline objects on the
* fly when executing draw calls.
*/
class DxvkShader : public RcObject {
public:
DxvkShader(
2017-10-14 23:52:47 +02:00
VkShaderStageFlagBits stage,
DxvkSpirvCodeBuffer&& code,
uint32_t numResourceSlots,
const DxvkResourceSlot* resourceSlots);
2017-10-11 23:28:06 +02:00
~DxvkShader();
/**
2017-10-14 23:52:47 +02:00
* \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
2017-10-11 23:28:06 +02:00
*/
2017-10-14 23:52:47 +02:00
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;
2017-10-11 23:28:06 +02:00
private:
2017-10-14 23:52:47 +02:00
VkShaderStageFlagBits m_stage;
DxvkSpirvCodeBuffer m_code;
std::vector<DxvkResourceSlot> m_slots;
2017-10-11 23:28:06 +02:00
};
}