Skip to content

Commit 4e9abff

Browse files
now compile MPV2 with SSBO
1 parent c3bae00 commit 4e9abff

File tree

4 files changed

+29
-18
lines changed

4 files changed

+29
-18
lines changed

examples_tests/41.VisibilityBuffer/main.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct BatchInstanceData
8080
struct
8181
{
8282
uint32_t invalid_0[3];
83-
uint32_t baseTriangle;
83+
uint32_t baseVertex;
8484
};
8585
};
8686
union
@@ -173,7 +173,7 @@ STextureData getTextureData(core::vector<commit_t>& _out_commits, const asset::I
173173
return addr;
174174
}
175175

176-
constexpr bool useSSBO = false;
176+
constexpr bool useSSBO = true;
177177

178178
int main()
179179
{
@@ -646,7 +646,10 @@ int main()
646646

647647
uint32_t writeCount,infoCount;
648648
if constexpr (useSSBO)
649-
writeCount = infoCount = gpump->getDescriptorSetWritesForSSBO(nullptr,nullptr,nullptr);
649+
{
650+
writeCount = gpump->getDescriptorSetWritesForSSBO(nullptr,nullptr,nullptr);
651+
infoCount = 2u;
652+
}
650653
else
651654
std::tie(writeCount,infoCount) = gpump->getDescriptorSetWritesForUTB(nullptr,nullptr,nullptr);
652655
vector<IGPUDescriptorSet::SWriteDescriptorSet> writesVG(++writeCount);
@@ -722,6 +725,7 @@ int main()
722725
SRasterizationParams{}
723726
);
724727
}
728+
#if 0
725729
{
726730
SPushConstantRange pcRange;
727731
pcRange.size = sizeof(core::vectorSIMDf); // TODO: send camera data
@@ -730,9 +734,10 @@ int main()
730734

731735
sceneData.shadeVBufferPpln = driver->createGPUComputePipeline(
732736
nullptr,driver->createGPUPipelineLayout(&pcRange,&pcRange+1,std::move(vtDSLayout),std::move(vgDSLayout),std::move(perFrameDSLayout),std::move(shadingDSLayout)),
733-
overrideShaderJustAfterVersionDirective("shadeVBuffer.comp")
737+
overrideShaderJustAfterVersionDirective("../shadeVBuffer.comp")
734738
);
735739
}
740+
#endif
736741
}
737742

738743
//! we want to move around the scene and view it from different angles
@@ -784,13 +789,13 @@ int main()
784789
sizeof(DrawElementsIndirectCommand_t)
785790
);
786791
}
787-
792+
#if 0
788793
// shade
789794
driver->bindDescriptorSets(video::EPBP_COMPUTE,sceneData.shadeVBufferPpln->getLayout(),0u,4u,ds,nullptr);
790795
driver->bindComputePipeline(sceneData.shadeVBufferPpln.get());
791796
driver->dispatch((params.WindowSize.Width-1u)/SHADING_WG_SIZE_X+1u,(params.WindowSize.Height-1u)/SHADING_WG_SIZE_Y+1u,1u);
792797
COpenGLExtensionHandler::extGlMemoryBarrier(GL_FRAMEBUFFER_BARRIER_BIT);
793-
798+
#endif
794799
// blit
795800
driver->blitRenderTargets(fb,0);
796801
driver->endScene();

examples_tests/41.VisibilityBuffer/shadeVBuffer.comp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ float nbl_glsl_VT_getVTexSzRcp()
5353
#define _NBL_USER_PROVIDED_VIRTUAL_TEXTURING_FUNCTIONS_
5454

5555

56-
vec4 nbl_glsl_vTextureGrad
57-
5856

5957
vec4 nbl_sample_Ka(in vec2 uv, in mat2 dUV) { return nbl_glsl_vTextureGrad(materialData[drawGUID].map_Ka_data, uv, dUV); }
6058

include/nbl/asset/utils/IMeshPackerV2.h

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ class IMeshPackerV2 : public IMeshPacker<MeshBufferType,MDIStructType>, public I
466466
result += "#define _NBL_VG_SSBO_UVEC4_BINDING " + std::to_string(params.uvec4BufferBinding) + '\n';
467467
}
468468

469+
result += "#define _NBL_VG_USE_SSBO_INDEX\n";
469470
result += "#define _NBL_VG_SSBO_INDEX_BINDING " + std::to_string(params.indexBufferBinding) + '\n';
470471
return result;
471472
}
@@ -504,31 +505,28 @@ class IMeshPackerV2 : public IMeshPacker<MeshBufferType,MDIStructType>, public I
504505
return bindingCount;
505506
}
506507

508+
// info count is always 2
507509
inline uint32_t getDescriptorSetWritesForSSBO(
508510
typename DescriptorSetType::SWriteDescriptorSet* outWrites, typename DescriptorSetType::SDescriptorInfo* outInfo, DescriptorSetType* dstSet,
509511
const DSLayoutParamsSSBO& params = {}
510512
) const
511513
{
512-
const uint32_t writeAndInfoCount = getDSlayoutBindingsForSSBO(nullptr);
514+
const uint32_t writeCount = getDSlayoutBindingsForSSBO(nullptr);
513515
if (!outWrites || !outInfo)
514-
return writeAndInfoCount;
515-
516-
outInfo->desc = vtxBuffer;
517-
outInfo->buffer.offset = 0u;
518-
outInfo->buffer.size = m_packerDataStore.vertexBuffer->getSize();
516+
return writeCount;
519517

520518
auto* write = outWrites;
519+
auto info = outInfo;
521520
auto fillWriteStruct = [&](uint32_t binding)
522521
{
523522
write->binding = binding;
524523
write->arrayElement = 0u;
525524
write->count = 1u;
526525
write->descriptorType = EDT_STORAGE_BUFFER;
527526
write->dstSet = dstSet;
528-
write->info = outInfo;
527+
write->info = info;
529528
write++;
530529
};
531-
532530
if (m_virtualAttribConfig.isUintBufferUsed)
533531
fillWriteStruct(params.uintBufferBinding);
534532
if (m_virtualAttribConfig.isUvec2BufferUsed)
@@ -537,8 +535,18 @@ class IMeshPackerV2 : public IMeshPacker<MeshBufferType,MDIStructType>, public I
537535
fillWriteStruct(params.uvec3BufferBinding);
538536
if (m_virtualAttribConfig.isUvec4BufferUsed)
539537
fillWriteStruct(params.uvec4BufferBinding);
538+
info->desc = m_packerDataStore.vertexBuffer;
539+
info->buffer.offset = 0u;
540+
info->buffer.size = m_packerDataStore.vertexBuffer->getSize();
541+
info++;
542+
543+
fillWriteStruct(params.indexBufferBinding);
544+
info->desc = m_packerDataStore.indexBuffer;
545+
info->buffer.offset = 0u;
546+
info->buffer.size = m_packerDataStore.indexBuffer->getSize();
547+
info++;
540548

541-
return writeAndInfoCount;
549+
return writeCount;
542550
}
543551

544552
template <typename MeshBufferIterator>

include/nbl/builtin/glsl/barycentric/frag.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ vec2 nbl_glsl_barycentric_frag_get();
2929
#define NBL_GLSL_BARYCENTRIC_FRAG_POS_INPUT
3030
#ifndef NBL_GLSL_BARYCENTRIC_FRAG_POS_INPUT_LOC
3131
#define NBL_GLSL_BARYCENTRIC_FRAG_POS_INPUT_LOC 0
32-
layout(location = NBL_GLSL_BARYCENTRIC_FRAG_POS_INPUT_LOC) in vec3 nbl_glsl_barycentric_frag_pos;
3332
#endif
33+
layout(location = NBL_GLSL_BARYCENTRIC_FRAG_POS_INPUT_LOC) in vec3 nbl_glsl_barycentric_frag_pos;
3434
#endif
3535
#ifndef NBL_GLSL_BARYCENTRIC_FRAG_PROVOKINGPOS_INPUT
3636
#define NBL_GLSL_BARYCENTRIC_FRAG_PROVOKINGPOS_INPUT

0 commit comments

Comments
 (0)