[mtl canvas, wip] Fixed wrong backdrop when segment ended right on tile's bottom boundary
This commit is contained in:
parent
93998852bb
commit
767841f9c6
|
@ -91,7 +91,7 @@ int main()
|
||||||
mg_fill();
|
mg_fill();
|
||||||
*/
|
*/
|
||||||
mg_move_to(400, 400);
|
mg_move_to(400, 400);
|
||||||
mg_quadratic_to(600, 600, 800, 400);
|
mg_quadratic_to(600, 601, 800, 400);
|
||||||
mg_close_path();
|
mg_close_path();
|
||||||
mg_set_color_rgba(0, 0, 1, 1);
|
mg_set_color_rgba(0, 0, 1, 1);
|
||||||
mg_fill();
|
mg_fill();
|
||||||
|
|
|
@ -79,6 +79,7 @@ typedef struct mg_mtl_tile_op
|
||||||
bool crossRight;
|
bool crossRight;
|
||||||
int windingOffset;
|
int windingOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
} mg_mtl_tile_op;
|
} mg_mtl_tile_op;
|
||||||
|
|
||||||
typedef struct mg_mtl_tile_queue
|
typedef struct mg_mtl_tile_queue
|
||||||
|
|
|
@ -180,7 +180,7 @@ void mtl_bin_segment_to_tiles(int segIndex,
|
||||||
bool test3 = mtl_is_left_of_segment(testPoint3, seg);
|
bool test3 = mtl_is_left_of_segment(testPoint3, seg);
|
||||||
|
|
||||||
if( test0 != test3
|
if( test0 != test3
|
||||||
&& seg->box.y <= testPoint0.y
|
&& seg->box.y < testPoint0.y
|
||||||
&& seg->box.w > testPoint0.y)
|
&& seg->box.w > testPoint0.y)
|
||||||
{
|
{
|
||||||
atomic_fetch_add_explicit(&tile->windingOffset, seg->windingIncrement, memory_order_relaxed);
|
atomic_fetch_add_explicit(&tile->windingOffset, seg->windingIncrement, memory_order_relaxed);
|
||||||
|
@ -268,16 +268,12 @@ void mtl_setup_monotonic_quadratic(thread float2* p,
|
||||||
device mg_mtl_tile_queue* tileQueueBuffer,
|
device mg_mtl_tile_queue* tileQueueBuffer,
|
||||||
device mg_mtl_tile_op* tileOpBuffer,
|
device mg_mtl_tile_op* tileOpBuffer,
|
||||||
device atomic_int* tileOpCount,
|
device atomic_int* tileOpCount,
|
||||||
int tileSize,
|
int tileSize)
|
||||||
int debugID)
|
|
||||||
{
|
{
|
||||||
//TODO: collapse with other segment kinds
|
//TODO: collapse with other segment kinds
|
||||||
int segIndex = atomic_fetch_add_explicit(segmentCount, 1, memory_order_relaxed);
|
int segIndex = atomic_fetch_add_explicit(segmentCount, 1, memory_order_relaxed);
|
||||||
device mg_mtl_segment* seg = &segmentBuffer[segIndex];
|
device mg_mtl_segment* seg = &segmentBuffer[segIndex];
|
||||||
|
|
||||||
|
|
||||||
seg->debugID = debugID;
|
|
||||||
|
|
||||||
seg->kind = MG_MTL_QUADRATIC;
|
seg->kind = MG_MTL_QUADRATIC;
|
||||||
seg->pathIndex = pathIndex;
|
seg->pathIndex = pathIndex;
|
||||||
seg->box = (vector_float4){min(p[0].x, p[2].x),
|
seg->box = (vector_float4){min(p[0].x, p[2].x),
|
||||||
|
@ -365,7 +361,6 @@ kernel void mtl_segment_setup(constant int* elementCount [[buffer(0)]],
|
||||||
int segIndex = atomic_fetch_add_explicit(segmentCount, 1, memory_order_relaxed);
|
int segIndex = atomic_fetch_add_explicit(segmentCount, 1, memory_order_relaxed);
|
||||||
device mg_mtl_segment* seg = &segmentBuffer[segIndex];
|
device mg_mtl_segment* seg = &segmentBuffer[segIndex];
|
||||||
|
|
||||||
seg->debugID = 0;
|
|
||||||
seg->kind = elt->kind;
|
seg->kind = elt->kind;
|
||||||
seg->pathIndex = elt->pathIndex;
|
seg->pathIndex = elt->pathIndex;
|
||||||
seg->box = (vector_float4){min(p0.x, p3.x),
|
seg->box = (vector_float4){min(p0.x, p3.x),
|
||||||
|
@ -408,8 +403,7 @@ kernel void mtl_segment_setup(constant int* elementCount [[buffer(0)]],
|
||||||
tileQueueBuffer,
|
tileQueueBuffer,
|
||||||
tileOpBuffer,
|
tileOpBuffer,
|
||||||
tileOpCount,
|
tileOpCount,
|
||||||
tileSize[0],
|
tileSize[0]);
|
||||||
1000 + count*10 + i);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -572,15 +566,6 @@ kernel void mtl_raster(const device int* screenTilesBuffer [[buffer(0)]],
|
||||||
{
|
{
|
||||||
const device mg_mtl_segment* seg = &segmentBuffer[op->index];
|
const device mg_mtl_segment* seg = &segmentBuffer[op->index];
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
if(seg->kind == MG_MTL_LINE && op->crossRight)
|
|
||||||
{
|
|
||||||
outTexture.write(float4(1, 0, 0, 1), uint2(pixelCoord));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if(pixelCoord.y >= seg->box.y && pixelCoord.y < seg->box.w)
|
if(pixelCoord.y >= seg->box.y && pixelCoord.y < seg->box.w)
|
||||||
{
|
{
|
||||||
if(mtl_is_left_of_segment(float2(pixelCoord), seg))
|
if(mtl_is_left_of_segment(float2(pixelCoord), seg))
|
||||||
|
|
Loading…
Reference in New Issue