Skip to content

Commit 2160c7f

Browse files
clear out texture on first batch. This fixes aliasing artifacts due to incorrect blending of old texture
1 parent 05d9c23 commit 2160c7f

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

samples/clock/src/main.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -112,35 +112,35 @@ ORCA_EXPORT void oc_on_frame_refresh(void)
112112

113113
oc_vec2 pos = oc_mat2x3_mul(transform, (oc_vec2){ clockRadius * 0.8f, 0 });
114114

115-
oc_set_color_rgba(0.2, 0.2, 0.2, 1);
115+
oc_set_color_srgba(0.2, 0.2, 0.2, 1);
116116
oc_text_fill(pos.x, pos.y, clockNumberStrings[i]);
117117
}
118118

119119
// hours hand
120120
oc_matrix_multiply_push(mat_transform(centerX, centerY, hoursRotation));
121121
{
122-
oc_set_color_rgba(.2, 0.2, 0.2, 1);
122+
oc_set_color_srgba(.2, 0.2, 0.2, 1);
123123
oc_rounded_rectangle_fill(0, -7.5 * uiScale, clockRadius * 0.5f, 15 * uiScale, 5 * uiScale);
124124
}
125125
oc_matrix_pop();
126126

127127
// minutes hand
128128
oc_matrix_multiply_push(mat_transform(centerX, centerY, minutesRotation));
129129
{
130-
oc_set_color_rgba(.2, 0.2, 0.2, 1);
130+
oc_set_color_srgba(.2, 0.2, 0.2, 1);
131131
oc_rounded_rectangle_fill(0, -5 * uiScale, clockRadius * 0.7f, 10 * uiScale, 5 * uiScale);
132132
}
133133
oc_matrix_pop();
134134

135135
// seconds hand
136136
oc_matrix_multiply_push(mat_transform(centerX, centerY, secondsRotation));
137137
{
138-
oc_set_color_rgba(1, 0.2, 0.2, 1);
138+
oc_set_color_srgba(1, 0.2, 0.2, 1);
139139
oc_rounded_rectangle_fill(0, -2.5 * uiScale, clockRadius * 0.8f, 5 * uiScale, 5 * uiScale);
140140
}
141141
oc_matrix_pop();
142142

143-
oc_set_color_rgba(.2, 0.2, 0.2, 1);
143+
oc_set_color_srgba(.2, 0.2, 0.2, 1);
144144
oc_circle_fill(centerX, centerY, 10 * uiScale);
145145

146146
oc_canvas_render(renderer, context, surface);

src/graphics/wgpu_renderer.c

+26-1
Original file line numberDiff line numberDiff line change
@@ -3327,7 +3327,32 @@ void oc_wgpu_canvas_submit(oc_canvas_renderer_base* rendererBase,
33273327
}
33283328

33293329
//----------------------------------------------------------------------------------------
3330-
//NOTE: clear texture
3330+
//NOTE: clear out texture if this is the first batch
3331+
if(batchCount == 0)
3332+
{
3333+
//clear out texture
3334+
WGPURenderPassDescriptor desc = {
3335+
.colorAttachmentCount = 1,
3336+
.colorAttachments = (WGPURenderPassColorAttachment[]){
3337+
{
3338+
.view = renderer->outTextureView,
3339+
.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED,
3340+
.loadOp = WGPULoadOp_Clear,
3341+
.storeOp = WGPUStoreOp_Store,
3342+
.clearValue = { 0, 0, 0, 0 },
3343+
},
3344+
},
3345+
};
3346+
3347+
WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(encoder, &desc);
3348+
{
3349+
wgpuRenderPassEncoderSetViewport(pass, 0.f, 0.f, screenSize.x, screenSize.y, 0.f, 1.f);
3350+
}
3351+
wgpuRenderPassEncoderEnd(pass);
3352+
}
3353+
3354+
//----------------------------------------------------------------------------------------
3355+
//NOTE: clear batch texture
33313356
{
33323357
WGPURenderPassDescriptor desc = {
33333358
.colorAttachmentCount = 1,

tests/perf/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ install_name_tool -add_rpath "@executable_path" $BINDIR/driver
1515

1616
cp Info.plist $BINDIR/
1717
cp $LIBDIR/liborca.dylib $BINDIR/
18-
cp $SRCDIR/ext/dawn/bin/libwebgpu.dylib $BINDIR/
18+
cp $LIBDIR/libwebgpu.dylib $BINDIR/

0 commit comments

Comments
 (0)