@@ -178,7 +178,13 @@ void DrawBuffersFiller::drawHatch(
178
178
/* something that gets you the texture id */
179
179
SIntendedSubmitInfo& intendedNextSubmit)
180
180
{
181
+ // TODO[Optimization Idea]: don't draw hatch twice if both colors are visible: instead do the msdf inside the alpha resolve by detecting mainObj being a hatch
182
+ // https://discord.com/channels/593902898015109131/856835291712716820/1228337893366300743
183
+ // TODO: Come back to this idea when doing color resolve for ecws (they don't have mainObj/style Index, instead they have uv into a texture
184
+
185
+ // if backgroundColor is visible
181
186
drawHatch (hatch, backgroundColor /* , invalid texture id to get solid fill */ , intendedNextSubmit);
187
+ // if foregroundColor is visible
182
188
// drawHatch(hatch, foregroundColor, /* valid texture id to get foreground pattern msdf fill */, intendedNextSubmit);
183
189
}
184
190
@@ -240,7 +246,7 @@ uint32_t DrawBuffersFiller::addMainObject_SubmitIfNeeded(uint32_t styleIdx, SInt
240
246
{
241
247
MainObject mainObject = {};
242
248
mainObject.styleIdx = styleIdx;
243
- mainObject.clipProjectionAddress = getCurrentClipProjectionAddress (intendedNextSubmit);
249
+ mainObject.clipProjectionAddress = acquireCurrentClipProjectionAddress (intendedNextSubmit);
244
250
uint32_t outMainObjectIdx = addMainObject_Internal (mainObject);
245
251
if (outMainObjectIdx == InvalidMainObjectIdx)
246
252
{
@@ -251,8 +257,9 @@ uint32_t DrawBuffersFiller::addMainObject_SubmitIfNeeded(uint32_t styleIdx, SInt
251
257
resetGeometryCounters ();
252
258
// mainObjects needs to be reset because we submitted every previous main object
253
259
resetMainObjectCounters ();
254
- // getCurrentClipProjectionAddress again here because clip projection exists in the geometry buffer, and reseting geometry counters will invalidate the current clip proj and requires repush
255
- mainObject.clipProjectionAddress = getCurrentClipProjectionAddress (intendedNextSubmit);
260
+
261
+ // acquireCurrentClipProjectionAddress again here because clip projection should exist in the geometry buffer, and reseting geometry counters will invalidate the current clip proj and requires repush
262
+ mainObject.clipProjectionAddress = acquireCurrentClipProjectionAddress (intendedNextSubmit);
256
263
outMainObjectIdx = addMainObject_Internal (mainObject);
257
264
assert (outMainObjectIdx != InvalidMainObjectIdx);
258
265
}
@@ -262,12 +269,14 @@ uint32_t DrawBuffersFiller::addMainObject_SubmitIfNeeded(uint32_t styleIdx, SInt
262
269
263
270
void DrawBuffersFiller::pushClipProjectionData (const ClipProjectionData& clipProjectionData)
264
271
{
265
- clipProjectionStack.push (clipProjectionData);
272
+ clipProjections.push (clipProjectionData);
273
+ clipProjectionAddresses.push_back (InvalidClipProjectionAddress);
266
274
}
267
275
268
276
void DrawBuffersFiller::popClipProjectionData ()
269
277
{
270
- clipProjectionStack.pop ();
278
+ clipProjections.pop ();
279
+ clipProjectionAddresses.pop_back ();
271
280
}
272
281
273
282
void DrawBuffersFiller::finalizeMainObjectCopiesToGPU (SIntendedSubmitInfo& intendedNextSubmit)
@@ -320,13 +329,13 @@ void DrawBuffersFiller::submitCurrentObjectsAndReset(SIntendedSubmitInfo& intend
320
329
// We don't reset counters for styles because we will be reusing them
321
330
resetGeometryCounters ();
322
331
323
- uint32_t newClipProjectionAddress = getCurrentClipProjectionAddress (intendedNextSubmit);
332
+ uint32_t newClipProjectionAddress = acquireCurrentClipProjectionAddress (intendedNextSubmit);
324
333
// If there clip projection stack is non-empty, then it means we need to re-push the clipProjectionData (because it exists in geometry data)
325
334
if (newClipProjectionAddress != InvalidClipProjectionAddress)
326
335
{
327
336
// then modify the mainObject data
328
337
getMainObject (mainObjectIndex)->clipProjectionAddress = newClipProjectionAddress;
329
- // we need to modify inMemMainObjectCount to this mainObjIndex so it re-uploads the current mainObject (because we modified it)
338
+ // we need to rewind back inMemMainObjectCount to this mainObjIndex so it re-uploads the current mainObject (because we modified it)
330
339
inMemMainObjectCount = min (inMemMainObjectCount, mainObjectIndex);
331
340
}
332
341
}
@@ -365,11 +374,15 @@ uint32_t DrawBuffersFiller::addLineStyle_Internal(const LineStyleInfo& lineStyle
365
374
return currentLineStylesCount++;
366
375
}
367
376
368
- inline uint64_t DrawBuffersFiller::getCurrentClipProjectionAddress (SIntendedSubmitInfo& intendedNextSubmit)
377
+ inline uint64_t DrawBuffersFiller::acquireCurrentClipProjectionAddress (SIntendedSubmitInfo& intendedNextSubmit)
369
378
{
370
- if (clipProjectionStackTopAddressInGPU == InvalidClipProjectionAddress && !clipProjectionStack.empty ())
371
- clipProjectionStackTopAddressInGPU = addClipProjectionData_SubmitIfNeeded (clipProjectionStack.top (), intendedNextSubmit);
372
- return clipProjectionStackTopAddressInGPU;
379
+ if (clipProjectionAddresses.empty ())
380
+ return InvalidClipProjectionAddress;
381
+
382
+ if (clipProjectionAddresses.back () == InvalidClipProjectionAddress)
383
+ clipProjectionAddresses.back () = addClipProjectionData_SubmitIfNeeded (clipProjections.top (), intendedNextSubmit);
384
+
385
+ return clipProjectionAddresses.back ();
373
386
}
374
387
375
388
uint64_t DrawBuffersFiller::addClipProjectionData_SubmitIfNeeded (const ClipProjectionData& clipProjectionData, SIntendedSubmitInfo& intendedNextSubmit)
0 commit comments