Skip to content

Commit 12b6c2c

Browse files
committed
DTM Task Comments
1 parent fd92730 commit 12b6c2c

File tree

6 files changed

+41
-1
lines changed

6 files changed

+41
-1
lines changed

62_CAD/DrawResourcesFiller.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ struct DrawResourcesFiller
6666
void setGlyphMSDFTextureFunction(const GetGlyphMSDFTextureFunc& func);
6767
void setHatchFillMSDFTextureFunction(const GetHatchFillPatternMSDFTextureFunc& func);
6868

69+
// TODO[Przemek]: try to draft up a `CTriangleMesh` Class in it's own header (like CPolyline), simplest form is basically two cpu buffers (1 array of uint index buffer, 1 array of float64_t3 vertexBuffer)
70+
// TODO[Przemek]: Then have a `drawMesh` function here similar to drawXXX's below, this will fit both vertex and index buffer in the `geometryBuffer`.
71+
// take a `SIntendedSubmitInfo` like others, but don't use it as I don't want you to handle anything regarding autoSubmit
72+
// somehow retrieve or calculate the geometry buffer offsets of your vertex and index buffer to be used outside for binding purposes
73+
6974
//! this function fills buffers required for drawing a polyline and submits a draw through provided callback when there is not enough memory.
7075
void drawPolyline(const CPolylineBase& polyline, const LineStyleInfo& lineStyleInfo, SIntendedSubmitInfo& intendedNextSubmit);
7176

@@ -193,6 +198,10 @@ struct DrawResourcesFiller
193198

194199
uint32_t addLineStyle_SubmitIfNeeded(const LineStyleInfo& lineStyle, SIntendedSubmitInfo& intendedNextSubmit);
195200

201+
// TODO[Przemek]: Read after reading the fragment shader comments and having a basic understanding of the relationship between "mainObject" and our programmable blending resolve:
202+
// Use `addMainObject_SubmitIfNeeded` to push your single mainObject you'll be using for the enitre triangle mesh (this will ensure overlaps between triangles of the same mesh is resolved correctly)
203+
// Delete comment when you understand this
204+
196205
// [ADVANCED] Do not use this function unless you know what you're doing (It may cause auto submit)
197206
// Never call this function multiple times in a row before indexing it in a drawable, because future auto-submits may invalidate mainObjects, so do them one by one, for example:
198207
// Valid: addMainObject1 --> addXXX(mainObj1) ---> addMainObject2 ---> addXXX(mainObj2) ....

62_CAD/main.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,8 +1378,17 @@ class ComputerAidedDesign final : public examples::SimpleWindowedApplication, pu
13781378
const uint32_t currentIndexCount = drawResourcesFiller.getDrawObjectCount() * 6u;
13791379
IGPUDescriptorSet* descriptorSets[] = { descriptorSet0.get(), descriptorSet1.get() };
13801380
cb->bindDescriptorSets(asset::EPBP_GRAPHICS, pipelineLayout.get(), 0u, 2u, descriptorSets);
1381+
1382+
// TODO[Przemek]: based on our call bind index buffer you uploaded to part of the `drawResourcesFiller.gpuDrawBuffers.geometryBuffer`
1383+
// Vertices will be pulled based on baseBDAPointer of where you uploaded the vertex + the VertexID in the vertex shader.
13811384
cb->bindIndexBuffer({ .offset = 0u, .buffer = drawResourcesFiller.gpuDrawBuffers.indexBuffer.get() }, asset::EIT_32BIT);
1385+
1386+
// TODO[Przemek]: binding the same pipelie, no need to change.
13821387
cb->bindGraphicsPipeline(graphicsPipeline.get());
1388+
1389+
// TODO[Przemek]: contour settings, height shading settings, base bda pointers will need to be pushed via pushConstants before the draw currently as it's the easiest thing to do.
1390+
1391+
// TODO[Przemek]: draw parameters needs to reflect the mesh involved
13831392
cb->drawIndexed(currentIndexCount, 1u, 0u, 0u, 0u);
13841393
if (fragmentShaderInterlockEnabled)
13851394
{
@@ -1477,6 +1486,9 @@ class ComputerAidedDesign final : public examples::SimpleWindowedApplication, pu
14771486

14781487
void addObjects(SIntendedSubmitInfo& intendedNextSubmit)
14791488
{
1489+
1490+
// TODO[Przemek]: add your own case, you won't call any other drawResourcesFiller function, only drawMesh with your custom made Mesh (for start it can be a single triangle)
1491+
14801492
// we record upload of our objects and if we failed to allocate we submit everything
14811493
if (!intendedNextSubmit.valid())
14821494
{

62_CAD/shaders/globals.hlsl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ static_assert(sizeof(CurveBox) == 80u);
260260
NBL_CONSTEXPR uint32_t InvalidRigidSegmentIndex = 0xffffffff;
261261
NBL_CONSTEXPR float InvalidStyleStretchValue = nbl::hlsl::numeric_limits<float>::infinity;
262262

263+
264+
// TODO[Przemek]: we will need something similar to LineStyles but related to heigh shading settings which is user customizable (like LineStyle stipple patterns) and requires upper_bound to figure out the color based on height value.
265+
// We'll discuss that later or what it will be looking like and how it's gonna get passed to our shaders.
266+
263267
// The color parameter is also used for styling non-curve objects such as text glyphs and hatches with solid color
264268
struct LineStyle
265269
{

62_CAD/shaders/main_pipeline/common.hlsl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ struct PrecomputedRootFinder
6262
}
6363
};
6464

65+
// TODO[Przemek]: your triangle mesh passed parameters from vtx to fragment will need to be here (e.g. height).
66+
// As always try to reuse parameters and try not to introduce new ones
6567
struct PSInput
6668
{
6769
float4 position : SV_Position;

62_CAD/shaders/main_pipeline/fragment_shader.hlsl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ float32_t4 calculateFinalColor<true>(const uint2 fragCoord, const float localAlp
372372
// if geomID has changed, we resolve the SDF alpha (draw using blend), else accumulate
373373
const bool resolve = currentMainObjectIdx != storedMainObjectIdx;
374374
uint32_t resolveStyleIdx = mainObjects[storedMainObjectIdx].styleIdx;
375+
376+
// TODO[Przemek]: REMOVE when READ --> if linestyle value in mainObject is invalid then we're using localTextureColor instead of the linestyle color, this should be true for DTM meshes to resolve color with what's stored in colorStorage and not from the lineStyle color
375377
const bool resolveColorFromStyle = resolveStyleIdx != InvalidStyleIdx;
376378

377379
// load from colorStorage only if we want to resolve color from texture instead of style
@@ -403,10 +405,13 @@ float32_t4 calculateFinalColor<true>(const uint2 fragCoord, const float localAlp
403405
float4 main(PSInput input) : SV_TARGET
404406
{
405407
float localAlpha = 0.0f;
408+
float3 textureColor = float3(0, 0, 0); // color sampled from a texture
409+
410+
411+
// TODO[Przemek]: Disable All the object rendering paths if you want.
406412
ObjectType objType = input.getObjType();
407413
const uint32_t currentMainObjectIdx = input.getMainObjectIdx();
408414
const MainObject mainObj = mainObjects[currentMainObjectIdx];
409-
float3 textureColor = float3(0, 0, 0); // color sampled from a texture
410415

411416
// figure out local alpha with sdf
412417
if (objType == ObjectType::LINE || objType == ObjectType::QUAD_BEZIER || objType == ObjectType::POLYLINE_CONNECTOR)
@@ -641,5 +646,9 @@ float4 main(PSInput input) : SV_TARGET
641646
if (localAlpha <= 0)
642647
discard;
643648

649+
650+
// TODO[Przemek]: But make sure you're still calling this, correctly calculating alpha and texture color.
651+
// you can add 1 main object and push via DrawResourcesFiller like we already do for other objects (this go in the mainObjects StorageBuffer) and then set the currentMainObjectIdx to 0 here
652+
// having 1 main object temporarily means that all triangle meshes will be treated as a unified object in blending operations.
644653
return calculateFinalColor<nbl::hlsl::jit::device_capabilities::fragmentShaderPixelInterlock>(fragCoord, localAlpha, currentMainObjectIdx, textureColor);
645654
}

62_CAD/shaders/main_pipeline/vertex_shader.hlsl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ void dilateHatch<false>(out float2 outOffsetVec, out float2 outUV, const float2
8787

8888
PSInput main(uint vertexID : SV_VertexID)
8989
{
90+
// TODO[Przemek]: Disable Everything here and do your own thing as we already discussed, but let's have the same PSInput data passed to fragment.
91+
// your programmable pulling will use the baseVertexBufferAddress BDA address and `vertexID` to RawBufferLoad it's vertex.
92+
// Later, most likely We will require pulling all 3 vertices of the triangle, that's where you need to know which triangle you're currently on, and instead of objectID = vertexID/4 which we currently do, you will do vertexID/3 and pull all 3 of it's vertices.
93+
9094
const uint vertexIdx = vertexID & 0x3u;
9195
const uint objectID = vertexID >> 2;
9296

0 commit comments

Comments
 (0)