Skip to content
Snippets Groups Projects
Commit 3042e8c1 authored by Alexander Gauggel's avatar Alexander Gauggel
Browse files

[#66] Put push constant data into struct

parent fbbe5021
No related branches found
No related tags found
1 merge request!54Resolve "Cmd/Sync-Rework"
...@@ -37,6 +37,13 @@ namespace vkcv ...@@ -37,6 +37,13 @@ namespace vkcv
size_t indexCount; size_t indexCount;
}; };
struct PushConstantData {
inline PushConstantData(void* data, size_t sizePerDrawcall) : data(data), sizePerDrawcall(sizePerDrawcall){}
void* data;
size_t sizePerDrawcall;
};
// forward declarations // forward declarations
class PassManager; class PassManager;
class PipelineManager; class PipelineManager;
...@@ -232,8 +239,7 @@ namespace vkcv ...@@ -232,8 +239,7 @@ namespace vkcv
void renderMesh( void renderMesh(
const PassHandle renderpassHandle, const PassHandle renderpassHandle,
const PipelineHandle pipelineHandle, const PipelineHandle pipelineHandle,
const size_t pushConstantSize, const PushConstantData &pushConstantData,
const void* pushConstantData,
const Mesh &mesh, const Mesh &mesh,
const std::vector<DescriptorSetUsage> &descriptorSets, const std::vector<DescriptorSetUsage> &descriptorSets,
const std::vector<ImageHandle> &renderTargets); const std::vector<ImageHandle> &renderTargets);
......
...@@ -164,8 +164,7 @@ int main(int argc, const char** argv) { ...@@ -164,8 +164,7 @@ int main(int argc, const char** argv) {
core.renderMesh( core.renderMesh(
trianglePass, trianglePass,
trianglePipeline, trianglePipeline,
sizeof(mvp), vkcv::PushConstantData((void*) &mvp, sizeof(mvp)),
&mvp,
boxMesh, boxMesh,
{ vkcv::DescriptorSetUsage(0, descriptorSet) }, { vkcv::DescriptorSetUsage(0, descriptorSet) },
{ swapchainInput, depthBuffer }); { swapchainInput, depthBuffer });
......
...@@ -144,8 +144,7 @@ namespace vkcv ...@@ -144,8 +144,7 @@ namespace vkcv
void Core::renderMesh( void Core::renderMesh(
const PassHandle renderpassHandle, const PassHandle renderpassHandle,
const PipelineHandle pipelineHandle, const PipelineHandle pipelineHandle,
const size_t pushConstantSize, const PushConstantData &pushConstantData,
const void *pushConstantData,
const Mesh &mesh, const Mesh &mesh,
const std::vector<DescriptorSetUsage> &descriptorSets, const std::vector<DescriptorSetUsage> &descriptorSets,
const std::vector<ImageHandle> &renderTargets) { const std::vector<ImageHandle> &renderTargets) {
...@@ -273,7 +272,14 @@ namespace vkcv ...@@ -273,7 +272,14 @@ namespace vkcv
const vk::Buffer indexBuffer = m_BufferManager->getBuffer(mesh.indexBuffer); const vk::Buffer indexBuffer = m_BufferManager->getBuffer(mesh.indexBuffer);
cmdBuffer.bindIndexBuffer(indexBuffer, 0, vk::IndexType::eUint16); //FIXME: choose proper size cmdBuffer.bindIndexBuffer(indexBuffer, 0, vk::IndexType::eUint16); //FIXME: choose proper size
cmdBuffer.pushConstants(pipelineLayout, vk::ShaderStageFlagBits::eAll, 0, pushConstantSize, pushConstantData);
cmdBuffer.pushConstants(
pipelineLayout,
vk::ShaderStageFlagBits::eAll,
0,
pushConstantData.sizePerDrawcall,
pushConstantData.data);
cmdBuffer.drawIndexed(mesh.indexCount, 1, 0, 0, {}); cmdBuffer.drawIndexed(mesh.indexCount, 1, 0, 0, {});
cmdBuffer.endRenderPass(); cmdBuffer.endRenderPass();
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment