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
size_t indexCount;
};
struct PushConstantData {
inline PushConstantData(void* data, size_t sizePerDrawcall) : data(data), sizePerDrawcall(sizePerDrawcall){}
void* data;
size_t sizePerDrawcall;
};
// forward declarations
class PassManager;
class PipelineManager;
......@@ -232,8 +239,7 @@ namespace vkcv
void renderMesh(
const PassHandle renderpassHandle,
const PipelineHandle pipelineHandle,
const size_t pushConstantSize,
const void* pushConstantData,
const PushConstantData &pushConstantData,
const Mesh &mesh,
const std::vector<DescriptorSetUsage> &descriptorSets,
const std::vector<ImageHandle> &renderTargets);
......
......@@ -164,8 +164,7 @@ int main(int argc, const char** argv) {
core.renderMesh(
trianglePass,
trianglePipeline,
sizeof(mvp),
&mvp,
vkcv::PushConstantData((void*) &mvp, sizeof(mvp)),
boxMesh,
{ vkcv::DescriptorSetUsage(0, descriptorSet) },
{ swapchainInput, depthBuffer });
......
......@@ -144,8 +144,7 @@ namespace vkcv
void Core::renderMesh(
const PassHandle renderpassHandle,
const PipelineHandle pipelineHandle,
const size_t pushConstantSize,
const void *pushConstantData,
const PushConstantData &pushConstantData,
const Mesh &mesh,
const std::vector<DescriptorSetUsage> &descriptorSets,
const std::vector<ImageHandle> &renderTargets) {
......@@ -273,7 +272,14 @@ namespace vkcv
const vk::Buffer indexBuffer = m_BufferManager->getBuffer(mesh.indexBuffer);
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.endRenderPass();
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment