1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-20 10:54:16 +01:00

[dxvk] Removed shader resource slots for now, needs work

This commit is contained in:
Philip Rebohle 2017-11-18 10:42:27 +01:00
parent a84e2eabc2
commit 745466652c
10 changed files with 77 additions and 141 deletions

View File

@ -112,8 +112,9 @@ namespace dxvk {
m_entryPointInterfaces.data());
m_module.setDebugName(m_entryPointId, "main");
return new DxvkShader(VK_SHADER_STAGE_FRAGMENT_BIT,
m_module.compile(), 0, nullptr);
return new DxvkShader(
VK_SHADER_STAGE_FRAGMENT_BIT,
m_module.compile());
}

View File

@ -119,8 +119,9 @@ namespace dxvk {
m_entryPointInterfaces.data());
m_module.setDebugName(m_entryPointId, "main");
return new DxvkShader(VK_SHADER_STAGE_VERTEX_BIT,
m_module.compile(), 0, nullptr);
return new DxvkShader(
VK_SHADER_STAGE_VERTEX_BIT,
m_module.compile());
}

View File

@ -9,9 +9,10 @@ namespace dxvk {
TRACE(this, shader);
std::vector<VkDescriptorSetLayoutBinding> bindings;
for (uint32_t i = 0; i < shader->slotCount(); i++)
bindings.push_back(shader->slotBinding(0, i));
// TODO re-implement shader slots and 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;
@ -39,7 +40,7 @@ namespace dxvk {
throw DxvkError("DxvkComputePipeline::DxvkComputePipeline: Failed to create pipeline layout");
}
SpirvCodeBuffer code = shader->code(0);
SpirvCodeBuffer code = shader->code();
VkShaderModuleCreateInfo minfo;
minfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;

View File

@ -35,7 +35,7 @@ namespace dxvk {
DxvkContextFlag::GpDirtyPipeline,
DxvkContextFlag::GpDirtyPipelineState,
DxvkContextFlag::GpDirtyResources,
DxvkContextFlag::GpDirtyIndexBuffers,
DxvkContextFlag::GpDirtyIndexBuffer,
DxvkContextFlag::GpDirtyVertexBuffers,
DxvkContextFlag::CpDirtyPipeline,
DxvkContextFlag::CpDirtyResources);
@ -83,7 +83,7 @@ namespace dxvk {
DxvkContextFlag::GpDirtyPipelineState,
DxvkContextFlag::GpDirtyResources,
DxvkContextFlag::GpDirtyVertexBuffers,
DxvkContextFlag::GpDirtyIndexBuffers);
DxvkContextFlag::GpDirtyIndexBuffer);
}
}
}

View File

@ -23,7 +23,7 @@ namespace dxvk {
GpDirtyPipelineState, ///< Graphics pipeline state (blending etc.) is dirty
GpDirtyResources, ///< Graphics pipeline resource 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
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
*
@ -69,6 +103,8 @@ namespace dxvk {
DxvkShaderStageState fs;
DxvkShaderStageState cs;
DxvkInputAssemblyState ia;
DxvkVertexInputState vi;
DxvkOutputMergerState om;
Rc<DxvkGraphicsPipeline> activeGraphicsPipeline;

View File

@ -56,15 +56,17 @@ namespace dxvk {
TRACE(this);
// TODO tune these values, if necessary
constexpr uint32_t MaxSets = 256;
constexpr uint32_t MaxSets = 64;
constexpr uint32_t MaxDesc = 256;
std::array<VkDescriptorPoolSize, 5> pools = {{
{ VK_DESCRIPTOR_TYPE_SAMPLER, MaxDesc },
{ VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, MaxDesc },
{ VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, MaxDesc },
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, MaxDesc },
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, MaxDesc } }};
std::array<VkDescriptorPoolSize, 7> pools = {{
{ VK_DESCRIPTOR_TYPE_SAMPLER, MaxDesc },
{ VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, MaxDesc },
{ VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, MaxDesc },
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, MaxDesc },
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, MaxDesc },
{ VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, MaxDesc },
{ VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, MaxDesc } }};
VkDescriptorPoolCreateInfo info;
info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;

View File

@ -3,13 +3,9 @@
namespace dxvk {
enum DxvkLimits : size_t {
MaxNumRenderTargets = 8,
MaxNumUniformBuffers = 16,
MaxNumSampledImages = 16,
MaxNumStorageBuffers = 128,
MaxNumStorageImages = 128,
MaxNumVertexBuffers = 32,
MaxNumOutputStreams = 4,
MaxNumRenderTargets = 8,
MaxNumVertexBuffers = 32,
MaxNumOutputStreams = 4,
};
}

View File

@ -4,15 +4,10 @@ namespace dxvk {
DxvkShader::DxvkShader(
VkShaderStageFlagBits stage,
SpirvCodeBuffer&& code,
uint32_t numResourceSlots,
const DxvkResourceSlot* resourceSlots)
SpirvCodeBuffer&& code)
: m_stage (stage),
m_code (std::move(code)) {
TRACE(this, stage, numResourceSlots);
for (uint32_t i = 0; i < numResourceSlots; i++)
m_slots.push_back(resourceSlots[i]);
TRACE(this, stage);
}
@ -20,38 +15,4 @@ namespace dxvk {
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;
}
}

View File

@ -8,19 +8,6 @@
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
*
@ -28,21 +15,13 @@ namespace dxvk {
* that can be accessed by shaders.
*/
enum class DxvkResourceType : uint32_t {
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,
};
/**
* \brief Resource slot
*/
struct DxvkResourceSlot{
DxvkResourceMode mode;
DxvkResourceType type;
uint32_t slot;
ImageSampler = VK_DESCRIPTOR_TYPE_SAMPLER,
SampledImage = VK_DESCRIPTOR_TYPE_SAMPLED_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,
};
@ -60,63 +39,22 @@ namespace dxvk {
DxvkShader(
VkShaderStageFlagBits stage,
SpirvCodeBuffer&& code,
uint32_t numResourceSlots,
const DxvkResourceSlot* resourceSlots);
SpirvCodeBuffer&& code);
~DxvkShader();
/**
* \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
* \returns Shader code buffer
*/
SpirvCodeBuffer 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;
const SpirvCodeBuffer& code() const {
return m_code;
}
private:
VkShaderStageFlagBits m_stage;
SpirvCodeBuffer m_code;
std::vector<DxvkResourceSlot> m_slots;
};
}

View File

@ -37,7 +37,7 @@ int WINAPI WinMain(HINSTANCE hInstance,
DxbcModule module(reader);
auto shader = module.compile();
shader->code(0).store(std::ofstream(
shader->code().store(std::ofstream(
str::fromws(argv[2]), std::ios::binary));
return 0;
} catch (const DxvkError& e) {