renderer: refactor/cleanup z/color surface binding.

This just makes the two functions look a lot more like each other,
since for texture views I have to add some more code to them.

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
macos/master
Dave Airlie 7 years ago
parent fd671742b9
commit 89eae094e5
  1. 34
      src/vrend_renderer.c

@ -1555,30 +1555,28 @@ void vrend_fb_bind_texture(struct vrend_resource *res,
static void vrend_hw_set_zsurf_texture(struct vrend_context *ctx) static void vrend_hw_set_zsurf_texture(struct vrend_context *ctx)
{ {
struct vrend_resource *tex; struct vrend_surface *surf = ctx->sub->zsurf;
uint32_t first_layer, last_layer;
if (!ctx->sub->zsurf) { if (!surf) {
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT,
GL_TEXTURE_2D, 0, 0); GL_TEXTURE_2D, 0, 0);
return; } else {
uint32_t first_layer = surf->val1 & 0xffff;
} uint32_t last_layer = (surf->val1 >> 16) & 0xffff;
tex = ctx->sub->zsurf->texture;
if (!tex)
return;
first_layer = ctx->sub->zsurf->val1 & 0xffff; if (!surf->texture)
last_layer = (ctx->sub->zsurf->val1 >> 16) & 0xffff; return;
vrend_fb_bind_texture(tex, 0, ctx->sub->zsurf->val0, vrend_fb_bind_texture(surf->texture, 0, surf->val0,
first_layer != last_layer ? 0xffffffff : first_layer); first_layer != last_layer ? 0xffffffff : first_layer);
}
} }
static void vrend_hw_set_color_surface(struct vrend_context *ctx, int index) static void vrend_hw_set_color_surface(struct vrend_context *ctx, int index)
{ {
struct vrend_resource *tex; struct vrend_surface *surf = ctx->sub->surf[index];
if (!ctx->sub->surf[index]) { if (!surf) {
GLenum attachment = GL_COLOR_ATTACHMENT0 + index; GLenum attachment = GL_COLOR_ATTACHMENT0 + index;
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachment, glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachment,
@ -1586,14 +1584,10 @@ static void vrend_hw_set_color_surface(struct vrend_context *ctx, int index)
} else { } else {
uint32_t first_layer = ctx->sub->surf[index]->val1 & 0xffff; uint32_t first_layer = ctx->sub->surf[index]->val1 & 0xffff;
uint32_t last_layer = (ctx->sub->surf[index]->val1 >> 16) & 0xffff; uint32_t last_layer = (ctx->sub->surf[index]->val1 >> 16) & 0xffff;
tex = ctx->sub->surf[index]->texture;
vrend_fb_bind_texture(surf->texture, index, surf->val0,
vrend_fb_bind_texture(tex, index, ctx->sub->surf[index]->val0,
first_layer != last_layer ? 0xffffffff : first_layer); first_layer != last_layer ? 0xffffffff : first_layer);
} }
} }
static void vrend_hw_emit_framebuffer_state(struct vrend_context *ctx) static void vrend_hw_emit_framebuffer_state(struct vrend_context *ctx)

Loading…
Cancel
Save