vulkan: move descriptor set logic into Shader

Using the extension VK_KHR_push_descriptor makes the code a lot easier.
Using it makes us able to set set descriptor sets dynamically.
This commit is contained in:
niki
2022-07-19 02:36:02 +02:00
parent 00974b5820
commit fb6457f57d
4 changed files with 275 additions and 224 deletions
+32 -5
View File
@@ -21,9 +21,11 @@ namespace love {
bool loadVolatile() override;
void unloadVolatile() override;
const std::vector<VkPipelineShaderStageCreateInfo>& getShaderStages() const {
return shaderStages;
}
const std::vector<VkPipelineShaderStageCreateInfo>& getShaderStages() const;
const VkPipelineLayout getGraphicsPipelineLayout() const;
void cmdPushDescriptorSets(VkCommandBuffer, uint32_t currentImage);
void attach() override;
@@ -43,11 +45,29 @@ namespace love {
bool hasUniform(const std::string& name) const override { return false; }
void setVideoTextures(graphics::Texture* ytexture, graphics::Texture* cbtexture, graphics::Texture* crtexture) override {}
void setVideoTextures(graphics::Texture* ytexture, graphics::Texture* cbtexture, graphics::Texture* crtexture) override;
// fixme: use normal methods for this in the future.
void setUniformData(BuiltinUniformData& data);
void setMainTex(graphics::Texture* texture);
private:
void compileShaders();
void createDescriptorSetLayout();
void createPipelineLayout();
void createStreamBuffers();
PFN_vkCmdPushDescriptorSetKHR vkCmdPushDescriptorSet;
VkDescriptorSetLayout descriptorSetLayout;
VkPipelineLayout pipelineLayout;
std::vector<StreamBuffer*> streamBuffers;
std::vector<VkPipelineShaderStageCreateInfo> shaderStages;
std::vector<VkShaderModule> shaderModules;
Graphics* gfx;
VkDevice device;
std::map<std::string, int> vertexAttributeIndices = {
{ "VertexPosition", 0 },
@@ -63,7 +83,14 @@ namespace love {
{ "MainTex", 4 }
};
std::map<std::string, UniformInfo> uniforms;
BuiltinUniformData uniformData;
graphics::Texture* mainTex;
graphics::Texture* ytexture;
graphics::Texture* cbtexture;
graphics::Texture* crtexture;
uint32_t currentImage;
uint32_t count;
};
}
}