mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-22 07:54:15 +01:00
[dxvk] Removed shader resource slots for now, needs work
This commit is contained in:
parent
a84e2eabc2
commit
745466652c
@ -112,8 +112,9 @@ namespace dxvk {
|
|||||||
m_entryPointInterfaces.data());
|
m_entryPointInterfaces.data());
|
||||||
m_module.setDebugName(m_entryPointId, "main");
|
m_module.setDebugName(m_entryPointId, "main");
|
||||||
|
|
||||||
return new DxvkShader(VK_SHADER_STAGE_FRAGMENT_BIT,
|
return new DxvkShader(
|
||||||
m_module.compile(), 0, nullptr);
|
VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||||
|
m_module.compile());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,8 +119,9 @@ namespace dxvk {
|
|||||||
m_entryPointInterfaces.data());
|
m_entryPointInterfaces.data());
|
||||||
m_module.setDebugName(m_entryPointId, "main");
|
m_module.setDebugName(m_entryPointId, "main");
|
||||||
|
|
||||||
return new DxvkShader(VK_SHADER_STAGE_VERTEX_BIT,
|
return new DxvkShader(
|
||||||
m_module.compile(), 0, nullptr);
|
VK_SHADER_STAGE_VERTEX_BIT,
|
||||||
|
m_module.compile());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,8 +10,9 @@ namespace dxvk {
|
|||||||
|
|
||||||
std::vector<VkDescriptorSetLayoutBinding> bindings;
|
std::vector<VkDescriptorSetLayoutBinding> bindings;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < shader->slotCount(); i++)
|
// TODO re-implement shader slots and bindings
|
||||||
bindings.push_back(shader->slotBinding(0, i));
|
// for (uint32_t i = 0; i < shader->slotCount(); i++)
|
||||||
|
// bindings.push_back(shader->slotBinding(0, i));
|
||||||
|
|
||||||
VkDescriptorSetLayoutCreateInfo dlayout;
|
VkDescriptorSetLayoutCreateInfo dlayout;
|
||||||
dlayout.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
dlayout.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
||||||
@ -39,7 +40,7 @@ namespace dxvk {
|
|||||||
throw DxvkError("DxvkComputePipeline::DxvkComputePipeline: Failed to create pipeline layout");
|
throw DxvkError("DxvkComputePipeline::DxvkComputePipeline: Failed to create pipeline layout");
|
||||||
}
|
}
|
||||||
|
|
||||||
SpirvCodeBuffer code = shader->code(0);
|
SpirvCodeBuffer code = shader->code();
|
||||||
|
|
||||||
VkShaderModuleCreateInfo minfo;
|
VkShaderModuleCreateInfo minfo;
|
||||||
minfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
minfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
||||||
|
@ -35,7 +35,7 @@ namespace dxvk {
|
|||||||
DxvkContextFlag::GpDirtyPipeline,
|
DxvkContextFlag::GpDirtyPipeline,
|
||||||
DxvkContextFlag::GpDirtyPipelineState,
|
DxvkContextFlag::GpDirtyPipelineState,
|
||||||
DxvkContextFlag::GpDirtyResources,
|
DxvkContextFlag::GpDirtyResources,
|
||||||
DxvkContextFlag::GpDirtyIndexBuffers,
|
DxvkContextFlag::GpDirtyIndexBuffer,
|
||||||
DxvkContextFlag::GpDirtyVertexBuffers,
|
DxvkContextFlag::GpDirtyVertexBuffers,
|
||||||
DxvkContextFlag::CpDirtyPipeline,
|
DxvkContextFlag::CpDirtyPipeline,
|
||||||
DxvkContextFlag::CpDirtyResources);
|
DxvkContextFlag::CpDirtyResources);
|
||||||
@ -83,7 +83,7 @@ namespace dxvk {
|
|||||||
DxvkContextFlag::GpDirtyPipelineState,
|
DxvkContextFlag::GpDirtyPipelineState,
|
||||||
DxvkContextFlag::GpDirtyResources,
|
DxvkContextFlag::GpDirtyResources,
|
||||||
DxvkContextFlag::GpDirtyVertexBuffers,
|
DxvkContextFlag::GpDirtyVertexBuffers,
|
||||||
DxvkContextFlag::GpDirtyIndexBuffers);
|
DxvkContextFlag::GpDirtyIndexBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ namespace dxvk {
|
|||||||
GpDirtyPipelineState, ///< Graphics pipeline state (blending etc.) is dirty
|
GpDirtyPipelineState, ///< Graphics pipeline state (blending etc.) is dirty
|
||||||
GpDirtyResources, ///< Graphics pipeline resource bindings are out of date
|
GpDirtyResources, ///< Graphics pipeline resource bindings are out of date
|
||||||
GpDirtyVertexBuffers, ///< Vertex buffer bindings are out of date
|
GpDirtyVertexBuffers, ///< Vertex buffer bindings are out of date
|
||||||
GpDirtyIndexBuffers, ///< Index buffer binding are out of date
|
GpDirtyIndexBuffer, ///< Index buffer binding are out of date
|
||||||
|
|
||||||
CpDirtyPipeline, ///< Compute pipeline binding are out of date
|
CpDirtyPipeline, ///< Compute pipeline binding are out of date
|
||||||
CpDirtyResources, ///< Compute pipeline resource bindings are out of date
|
CpDirtyResources, ///< Compute pipeline resource bindings are out of date
|
||||||
@ -44,6 +44,40 @@ namespace dxvk {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Input assembly state
|
||||||
|
*
|
||||||
|
* Stores the primitive topology
|
||||||
|
* and the vertex input layout.
|
||||||
|
*/
|
||||||
|
struct DxvkInputAssemblyState {
|
||||||
|
VkPrimitiveTopology primitiveTopology;
|
||||||
|
VkBool32 primitiveRestart;
|
||||||
|
|
||||||
|
uint32_t numVertexBindings = 0;
|
||||||
|
uint32_t numVertexAttributes = 0;
|
||||||
|
|
||||||
|
std::array<VkVertexInputBindingDescription,
|
||||||
|
DxvkLimits::MaxNumVertexBuffers> vertexBindings;
|
||||||
|
|
||||||
|
std::array<VkVertexInputAttributeDescription,
|
||||||
|
DxvkLimits::MaxNumVertexBuffers> vertexAttributes;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Vertex input state
|
||||||
|
*
|
||||||
|
* Stores the currently bound index
|
||||||
|
* buffer and vertex buffers.
|
||||||
|
*/
|
||||||
|
struct DxvkVertexInputState {
|
||||||
|
Rc<DxvkBuffer> indexBuffer;
|
||||||
|
std::array<Rc<DxvkBuffer>,
|
||||||
|
DxvkLimits::MaxNumVertexBuffers> vertexBuffers;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Output merger state
|
* \brief Output merger state
|
||||||
*
|
*
|
||||||
@ -69,6 +103,8 @@ namespace dxvk {
|
|||||||
DxvkShaderStageState fs;
|
DxvkShaderStageState fs;
|
||||||
DxvkShaderStageState cs;
|
DxvkShaderStageState cs;
|
||||||
|
|
||||||
|
DxvkInputAssemblyState ia;
|
||||||
|
DxvkVertexInputState vi;
|
||||||
DxvkOutputMergerState om;
|
DxvkOutputMergerState om;
|
||||||
|
|
||||||
Rc<DxvkGraphicsPipeline> activeGraphicsPipeline;
|
Rc<DxvkGraphicsPipeline> activeGraphicsPipeline;
|
||||||
|
@ -56,15 +56,17 @@ namespace dxvk {
|
|||||||
TRACE(this);
|
TRACE(this);
|
||||||
|
|
||||||
// TODO tune these values, if necessary
|
// TODO tune these values, if necessary
|
||||||
constexpr uint32_t MaxSets = 256;
|
constexpr uint32_t MaxSets = 64;
|
||||||
constexpr uint32_t MaxDesc = 256;
|
constexpr uint32_t MaxDesc = 256;
|
||||||
|
|
||||||
std::array<VkDescriptorPoolSize, 5> pools = {{
|
std::array<VkDescriptorPoolSize, 7> pools = {{
|
||||||
{ VK_DESCRIPTOR_TYPE_SAMPLER, MaxDesc },
|
{ VK_DESCRIPTOR_TYPE_SAMPLER, MaxDesc },
|
||||||
{ VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, MaxDesc },
|
{ VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, MaxDesc },
|
||||||
{ VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, MaxDesc },
|
{ VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, MaxDesc },
|
||||||
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, MaxDesc },
|
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, MaxDesc },
|
||||||
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, MaxDesc } }};
|
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, MaxDesc },
|
||||||
|
{ VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, MaxDesc },
|
||||||
|
{ VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, MaxDesc } }};
|
||||||
|
|
||||||
VkDescriptorPoolCreateInfo info;
|
VkDescriptorPoolCreateInfo info;
|
||||||
info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
||||||
|
@ -4,10 +4,6 @@ namespace dxvk {
|
|||||||
|
|
||||||
enum DxvkLimits : size_t {
|
enum DxvkLimits : size_t {
|
||||||
MaxNumRenderTargets = 8,
|
MaxNumRenderTargets = 8,
|
||||||
MaxNumUniformBuffers = 16,
|
|
||||||
MaxNumSampledImages = 16,
|
|
||||||
MaxNumStorageBuffers = 128,
|
|
||||||
MaxNumStorageImages = 128,
|
|
||||||
MaxNumVertexBuffers = 32,
|
MaxNumVertexBuffers = 32,
|
||||||
MaxNumOutputStreams = 4,
|
MaxNumOutputStreams = 4,
|
||||||
};
|
};
|
||||||
|
@ -4,15 +4,10 @@ namespace dxvk {
|
|||||||
|
|
||||||
DxvkShader::DxvkShader(
|
DxvkShader::DxvkShader(
|
||||||
VkShaderStageFlagBits stage,
|
VkShaderStageFlagBits stage,
|
||||||
SpirvCodeBuffer&& code,
|
SpirvCodeBuffer&& code)
|
||||||
uint32_t numResourceSlots,
|
|
||||||
const DxvkResourceSlot* resourceSlots)
|
|
||||||
: m_stage (stage),
|
: m_stage (stage),
|
||||||
m_code (std::move(code)) {
|
m_code (std::move(code)) {
|
||||||
TRACE(this, stage, numResourceSlots);
|
TRACE(this, stage);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < numResourceSlots; i++)
|
|
||||||
m_slots.push_back(resourceSlots[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -20,38 +15,4 @@ namespace dxvk {
|
|||||||
TRACE(this);
|
TRACE(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SpirvCodeBuffer 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<VkDescriptorType>(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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -8,19 +8,6 @@
|
|||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Resource access mode
|
|
||||||
*
|
|
||||||
* Defines whether a resource will be
|
|
||||||
* used for reading, writing, or both.
|
|
||||||
*/
|
|
||||||
enum class DxvkResourceModeBit : uint32_t {
|
|
||||||
Read = 0,
|
|
||||||
Write = 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
using DxvkResourceMode = Flags<DxvkResourceModeBit>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Shader resource type
|
* \brief Shader resource type
|
||||||
*
|
*
|
||||||
@ -28,21 +15,13 @@ namespace dxvk {
|
|||||||
* that can be accessed by shaders.
|
* that can be accessed by shaders.
|
||||||
*/
|
*/
|
||||||
enum class DxvkResourceType : uint32_t {
|
enum class DxvkResourceType : uint32_t {
|
||||||
UniformBuffer = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
|
||||||
ImageSampler = VK_DESCRIPTOR_TYPE_SAMPLER,
|
ImageSampler = VK_DESCRIPTOR_TYPE_SAMPLER,
|
||||||
SampledImage = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
SampledImage = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
||||||
StorageBuffer = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
|
||||||
StorageImage = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
StorageImage = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
||||||
};
|
UniformBuffer = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
||||||
|
StorageBuffer = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||||
|
UniformTexelBuffer = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
|
||||||
/**
|
StorageTexelBuffer = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
|
||||||
* \brief Resource slot
|
|
||||||
*/
|
|
||||||
struct DxvkResourceSlot{
|
|
||||||
DxvkResourceMode mode;
|
|
||||||
DxvkResourceType type;
|
|
||||||
uint32_t slot;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -60,63 +39,22 @@ namespace dxvk {
|
|||||||
|
|
||||||
DxvkShader(
|
DxvkShader(
|
||||||
VkShaderStageFlagBits stage,
|
VkShaderStageFlagBits stage,
|
||||||
SpirvCodeBuffer&& code,
|
SpirvCodeBuffer&& code);
|
||||||
uint32_t numResourceSlots,
|
|
||||||
const DxvkResourceSlot* resourceSlots);
|
|
||||||
~DxvkShader();
|
~DxvkShader();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Retrieves shader code
|
* \brief Retrieves shader code
|
||||||
*
|
* \returns Shader code buffer
|
||||||
* 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
|
|
||||||
*/
|
*/
|
||||||
SpirvCodeBuffer code(
|
const SpirvCodeBuffer& code() const {
|
||||||
uint32_t bindingOffset) const;
|
return m_code;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* \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:
|
private:
|
||||||
|
|
||||||
VkShaderStageFlagBits m_stage;
|
VkShaderStageFlagBits m_stage;
|
||||||
SpirvCodeBuffer m_code;
|
SpirvCodeBuffer m_code;
|
||||||
|
|
||||||
std::vector<DxvkResourceSlot> m_slots;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
@ -37,7 +37,7 @@ int WINAPI WinMain(HINSTANCE hInstance,
|
|||||||
DxbcModule module(reader);
|
DxbcModule module(reader);
|
||||||
|
|
||||||
auto shader = module.compile();
|
auto shader = module.compile();
|
||||||
shader->code(0).store(std::ofstream(
|
shader->code().store(std::ofstream(
|
||||||
str::fromws(argv[2]), std::ios::binary));
|
str::fromws(argv[2]), std::ios::binary));
|
||||||
return 0;
|
return 0;
|
||||||
} catch (const DxvkError& e) {
|
} catch (const DxvkError& e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user