Skip to content
Snippets Groups Projects
Verified Commit b93152ea authored by Tobias Frisch's avatar Tobias Frisch
Browse files

Moved drawcall recording into core hiding internal calls

parent 09cc9ce9
No related branches found
No related tags found
1 merge request!103Added project wobble_bobble and refactored some parts of the framework
...@@ -52,8 +52,6 @@ namespace vkcv { ...@@ -52,8 +52,6 @@ namespace vkcv {
}; };
vk::IndexType getIndexType(IndexBitCount indexByteCount);
struct DrawcallInfo { struct DrawcallInfo {
inline DrawcallInfo(const Mesh& mesh, const std::vector<DescriptorSetUsage>& descriptorSets, const uint32_t instanceCount = 1) inline DrawcallInfo(const Mesh& mesh, const std::vector<DescriptorSetUsage>& descriptorSets, const uint32_t instanceCount = 1)
: mesh(mesh), descriptorSets(descriptorSets), instanceCount(instanceCount){} : mesh(mesh), descriptorSets(descriptorSets), instanceCount(instanceCount){}
...@@ -63,23 +61,6 @@ namespace vkcv { ...@@ -63,23 +61,6 @@ namespace vkcv {
uint32_t instanceCount; uint32_t instanceCount;
}; };
void recordDrawcall(
const Core &core,
const DrawcallInfo &drawcall,
vk::CommandBuffer cmdBuffer,
vk::PipelineLayout pipelineLayout,
const PushConstants &pushConstants,
const size_t drawcallIndex);
void recordIndirectDrawcall(
const DrawcallInfo &drawcall,
vk::CommandBuffer cmdBuffer,
const vkcv::Buffer<vk::DrawIndexedIndirectCommand> &drawBuffer,
const uint32_t drawCount,
vk::PipelineLayout pipelineLayout,
const PushConstants &pushConstants,
const size_t drawcallIndex);
void InitMeshShaderDrawFunctions(vk::Device device); void InitMeshShaderDrawFunctions(vk::Device device);
struct MeshShaderDrawcall { struct MeshShaderDrawcall {
......
...@@ -268,6 +268,56 @@ namespace vkcv ...@@ -268,6 +268,56 @@ namespace vkcv
cmdBuffer.setViewport(0, 1, &dynamicViewport); cmdBuffer.setViewport(0, 1, &dynamicViewport);
cmdBuffer.setScissor(0, 1, &dynamicScissor); cmdBuffer.setScissor(0, 1, &dynamicScissor);
} }
vk::IndexType getIndexType(IndexBitCount indexByteCount){
switch (indexByteCount) {
case IndexBitCount::Bit16: return vk::IndexType::eUint16;
case IndexBitCount::Bit32: return vk::IndexType::eUint32;
default:
vkcv_log(LogLevel::ERROR, "unknown Enum");
return vk::IndexType::eUint16;
}
}
void recordDrawcall(
const Core &core,
const DrawcallInfo &drawcall,
vk::CommandBuffer cmdBuffer,
vk::PipelineLayout pipelineLayout,
const PushConstants &pushConstants,
const size_t drawcallIndex) {
for (uint32_t i = 0; i < drawcall.mesh.vertexBufferBindings.size(); i++) {
const auto& vertexBinding = drawcall.mesh.vertexBufferBindings[i];
cmdBuffer.bindVertexBuffers(i, vertexBinding.buffer, vertexBinding.offset);
}
for (const auto& descriptorUsage : drawcall.descriptorSets) {
cmdBuffer.bindDescriptorSets(
vk::PipelineBindPoint::eGraphics,
pipelineLayout,
descriptorUsage.setLocation,
core.getDescriptorSet(descriptorUsage.descriptorSet).vulkanHandle,
nullptr);
}
if (pushConstants.getSizePerDrawcall() > 0) {
cmdBuffer.pushConstants(
pipelineLayout,
vk::ShaderStageFlagBits::eAll,
0,
pushConstants.getSizePerDrawcall(),
pushConstants.getDrawcallData(drawcallIndex));
}
if (drawcall.mesh.indexBuffer) {
cmdBuffer.bindIndexBuffer(drawcall.mesh.indexBuffer, 0, getIndexType(drawcall.mesh.indexBitCount));
cmdBuffer.drawIndexed(drawcall.mesh.indexCount, drawcall.instanceCount, 0, 0, {});
}
else {
cmdBuffer.draw(drawcall.mesh.indexCount, drawcall.instanceCount, 0, 0, {});
}
}
void Core::recordDrawcallsToCmdStream( void Core::recordDrawcallsToCmdStream(
const CommandStreamHandle& cmdStreamHandle, const CommandStreamHandle& cmdStreamHandle,
......
...@@ -5,67 +5,6 @@ ...@@ -5,67 +5,6 @@
namespace vkcv { namespace vkcv {
vk::IndexType getIndexType(IndexBitCount indexByteCount){
switch (indexByteCount) {
case IndexBitCount::Bit16: return vk::IndexType::eUint16;
case IndexBitCount::Bit32: return vk::IndexType::eUint32;
default:
vkcv_log(LogLevel::ERROR, "unknown Enum");
return vk::IndexType::eUint16;
}
}
void recordDrawcall(
const Core &core,
const DrawcallInfo &drawcall,
vk::CommandBuffer cmdBuffer,
vk::PipelineLayout pipelineLayout,
const PushConstants &pushConstants,
const size_t drawcallIndex) {
for (uint32_t i = 0; i < drawcall.mesh.vertexBufferBindings.size(); i++) {
const auto& vertexBinding = drawcall.mesh.vertexBufferBindings[i];
cmdBuffer.bindVertexBuffers(i, vertexBinding.buffer, vertexBinding.offset);
}
for (const auto& descriptorUsage : drawcall.descriptorSets) {
cmdBuffer.bindDescriptorSets(
vk::PipelineBindPoint::eGraphics,
pipelineLayout,
descriptorUsage.setLocation,
core.getDescriptorSet(descriptorUsage.descriptorSet).vulkanHandle,
nullptr);
}
if (pushConstants.getSizePerDrawcall() > 0) {
cmdBuffer.pushConstants(
pipelineLayout,
vk::ShaderStageFlagBits::eAll,
0,
pushConstants.getSizePerDrawcall(),
pushConstants.getDrawcallData(drawcallIndex));
}
if (drawcall.mesh.indexBuffer) {
cmdBuffer.bindIndexBuffer(drawcall.mesh.indexBuffer, 0, getIndexType(drawcall.mesh.indexBitCount));
cmdBuffer.drawIndexed(drawcall.mesh.indexCount, drawcall.instanceCount, 0, 0, {});
}
else {
cmdBuffer.draw(drawcall.mesh.indexCount, drawcall.instanceCount, 0, 0, {});
}
}
void recordIndirectDrawcall(
const DrawcallInfo &drawcall,
vk::CommandBuffer cmdBuffer,
const Buffer <vk::DrawIndexedIndirectCommand> &drawBuffer,
const uint32_t drawCount,
vk::PipelineLayout pipelineLayout,
const PushConstants &pushConstants,
const size_t drawcallIndex) {
return;
}
struct MeshShaderFunctions struct MeshShaderFunctions
{ {
PFN_vkCmdDrawMeshTasksNV cmdDrawMeshTasks = nullptr; PFN_vkCmdDrawMeshTasksNV cmdDrawMeshTasks = nullptr;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment