Skip to content

Commit

Permalink
drivers/glrend: check if render targets are valid
Browse files Browse the repository at this point in the history
  • Loading branch information
erysdren committed Feb 9, 2024
1 parent 3add39e commit 02e9648
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion drivers/glrend/renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ br_renderer *RendererGLAllocate(br_device *device, br_renderer_facility *facilit

static void BR_CMETHOD_DECL(br_renderer_gl, sceneBegin)(br_renderer *self)
{
HVIDEO hVideo = &self->pixelmap->screen->asFront.video;
HVIDEO hVideo = &self->pixelmap->screen->asFront.video;
br_device_pixelmap *colour_target = NULL, *depth_target = NULL;

self->stats.face_group_count = 0;
self->stats.triangles_drawn_count = 0;
Expand All @@ -70,6 +71,26 @@ static void BR_CMETHOD_DECL(br_renderer_gl, sceneBegin)(br_renderer *self)
while(glGetError() != GL_NO_ERROR)
;

if(self->state.current->valid & BR_STATE_OUTPUT) {
colour_target = self->state.current->output.colour;
depth_target = self->state.current->output.depth;
}

if(colour_target != NULL && ObjectDevice(colour_target) != self->device) {
BR_ERROR0("Can't render to a non-device colour pixelmap");
}

if(depth_target != NULL && ObjectDevice(depth_target) != self->device) {
BR_ERROR0("Can't render to a non-device depth pixelmap");
}

/*
* TODO: Consider if we want to handle depth-only renders.
*/
if(colour_target == NULL) {
BR_ERROR("Can't render without a destination");
}

GLCACHE_Reset(&self->state.cache);
GLCACHE_UpdateScene(&self->state.cache, self->state.current);

Expand Down

0 comments on commit 02e9648

Please sign in to comment.