[wip, win32, canvas] wip trying to fix multiple shapes

This commit is contained in:
martinfouilleul 2023-07-02 12:26:54 +02:00
parent 7628138cee
commit b61d8868d3
5 changed files with 39 additions and 23 deletions

View File

@ -16,8 +16,6 @@
#include"milepost.h"
#define LOG_SUBSYSTEM "Main"
int main()
{
mp_init();
@ -111,7 +109,6 @@ int main()
mg_set_color_rgba(1, 0, 0, 1);
mg_fill();
/*
mg_move_to(200, 100);
mg_line_to(410, 100);
mg_line_to(410, 200);
@ -119,7 +116,7 @@ int main()
mg_close_path();
mg_set_color_rgba(0, 1, 0, 1);
mg_fill();
/*
mg_move_to(400, 400);
mg_quadratic_to(600, 601, 800, 400);
mg_close_path();

View File

@ -273,16 +273,13 @@ void mg_gl_render_batch(mg_gl_canvas_backend* backend,
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
//NOTE: backprop pass
/*
glUseProgram(backend->backprop);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, backend->tileQueueBuffer);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, backend->pathQueueBuffer);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, backend->tileQueueBuffer);
glUniform2i(0, nTilesX, nTilesY);
glDispatchCompute(nTilesY, 1, 1);
glDispatchCompute(pathCount, 1, 1);
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
*/
//NOTE: merge pass
glUseProgram(backend->merge);

View File

@ -1,26 +1,49 @@
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(local_size_x = 16, local_size_y = 1, local_size_z = 1) in;
precision mediump float;
layout(std430) buffer;
layout(binding = 0) restrict buffer tileQueueBufferSSBO
layout(binding = 0) restrict readonly buffer pathQueueBufferSSBO
{
mg_gl_path_queue elements[];
} pathQueueBuffer;
layout(binding = 1) restrict buffer tileQueueBufferSSBO
{
mg_gl_tile_queue elements[];
} tileQueueBuffer;
layout(location = 0) uniform ivec2 nTiles;
shared int nextRowIndex;
void main()
{
int rowIndex = int(gl_WorkGroupID.x);
int pathIndex = int(gl_WorkGroupID.x);
int localID = int(gl_LocalInvocationID.x);
int sum = 0;
for(int x = nTiles.x-1; x >= 0; x--)
if(localID == 0)
{
int tileIndex = rowIndex * nTiles.x + x;
int offset = tileQueueBuffer.elements[tileIndex].windingOffset;
tileQueueBuffer.elements[tileIndex].windingOffset = sum;
sum += offset;
nextRowIndex = 0;
}
barrier();
int rowIndex = 0;
mg_gl_path_queue pathQueue = pathQueueBuffer.elements[pathIndex];
int tileQueueBase = pathQueue.tileQueues;
int rowSize = pathQueue.area.z;
int rowCount = pathQueue.area.w;
rowIndex = atomicAdd(nextRowIndex, 1);
while(rowIndex < rowCount)
{
int sum = 0;
for(int x = rowSize-1; x >= 0; x--)
{
int tileIndex = tileQueueBase + rowIndex * rowSize.x + x;
int offset = tileQueueBuffer.elements[tileIndex].windingOffset;
tileQueueBuffer.elements[tileIndex].windingOffset = sum;
sum += offset;
}
rowIndex = atomicAdd(nextRowIndex, 1);
}
}

View File

@ -45,7 +45,6 @@ void main()
int tileIndex = tileCoord.y * nTiles.x + tileCoord.x;
screenTilesBuffer.elements[tileIndex] = -1;
int lastOpIndex = -1;
for(int pathIndex = 0; pathIndex < pathCount; pathIndex++)

View File

@ -150,8 +150,8 @@ void main()
while(opIndex >= 0)
{
//imageStore(outTexture, ivec2(sampleCoord), vec4(0, 1, 0, 1));
//return;
// imageStore(outTexture, ivec2(sampleCoord), vec4(0, 1, 1, 1));
// return;
mg_gl_tile_op op = tileOpBuffer.elements[opIndex];
opIndex = op.next;