mesa: Track number of layers in layered framebuffers.
In order to properly clear layered framebuffers, we need to know how many layers they have. The easiest way to do this is to record it in the gl_framebuffer struct when we check framebuffer completeness. This patch replaces the gl_framebuffer::Layered boolean with a gl_framebuffer::NumLayers integer, which is 0 if the framebuffer is not layered, and equal to the number of layers otherwise. v2: Remove gl_framebuffer::Layered and make gl_framebuffer::NumLayers always have a defined value. Fix factor of 6 error in the number of layers in a cube map array. Cc: "10.0" <mesa-stable@lists.freedesktop.org> Reviewed-by: Chris Forbes <chrisf@ijw.co.nz> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
parent
085ad4821e
commit
95140740ad
|
@ -701,7 +701,7 @@ brw_update_renderbuffer_surfaces(struct brw_context *brw)
|
|||
for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
|
||||
if (intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[i])) {
|
||||
brw->vtbl.update_renderbuffer_surface(brw, ctx->DrawBuffer->_ColorDrawBuffers[i],
|
||||
ctx->DrawBuffer->Layered, i);
|
||||
ctx->DrawBuffer->NumLayers > 0, i);
|
||||
} else {
|
||||
brw->vtbl.update_null_renderbuffer_surface(brw, i);
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ upload_clip_state(struct brw_context *brw)
|
|||
dw2);
|
||||
OUT_BATCH(U_FIXED(0.125, 3) << GEN6_CLIP_MIN_POINT_WIDTH_SHIFT |
|
||||
U_FIXED(255.875, 3) << GEN6_CLIP_MAX_POINT_WIDTH_SHIFT |
|
||||
(fb->Layered ? 0 : GEN6_CLIP_FORCE_ZERO_RTAINDEX));
|
||||
(fb->NumLayers > 0 ? 0 : GEN6_CLIP_FORCE_ZERO_RTAINDEX));
|
||||
ADVANCE_BATCH();
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ gen7_emit_depth_stencil_hiz(struct brw_context *brw,
|
|||
break;
|
||||
}
|
||||
|
||||
if (fb->Layered || !irb) {
|
||||
if (fb->NumLayers > 0 || !irb) {
|
||||
min_array_element = 0;
|
||||
} else if (irb->mt->num_samples > 1) {
|
||||
/* Convert physical layer to logical layer. */
|
||||
|
|
|
@ -905,6 +905,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
|
|||
struct gl_renderbuffer_attachment *att;
|
||||
GLenum f;
|
||||
gl_format attFormat;
|
||||
GLenum att_tex_target = GL_NONE;
|
||||
|
||||
/*
|
||||
* XXX for ARB_fbo, only check color buffers that are named by
|
||||
|
@ -945,6 +946,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
|
|||
*/
|
||||
if (att->Type == GL_TEXTURE) {
|
||||
const struct gl_texture_image *texImg = att->Renderbuffer->TexImage;
|
||||
att_tex_target = att->Texture->Target;
|
||||
minWidth = MIN2(minWidth, texImg->Width);
|
||||
maxWidth = MAX2(maxWidth, texImg->Width);
|
||||
minHeight = MIN2(minHeight, texImg->Height);
|
||||
|
@ -1057,7 +1059,14 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
|
|||
}
|
||||
|
||||
/* Check that layered rendering is consistent. */
|
||||
att_layer_count = att->Layered ? att->Renderbuffer->Depth : 0;
|
||||
if (att->Layered) {
|
||||
if (att_tex_target == GL_TEXTURE_CUBE_MAP)
|
||||
att_layer_count = 6;
|
||||
else
|
||||
att_layer_count = att->Renderbuffer->Depth;
|
||||
} else {
|
||||
att_layer_count = 0;
|
||||
}
|
||||
if (!layer_count_valid) {
|
||||
layer_count = att_layer_count;
|
||||
layer_count_valid = true;
|
||||
|
@ -1073,7 +1082,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
|
|||
}
|
||||
}
|
||||
|
||||
fb->Layered = layer_count > 0;
|
||||
fb->NumLayers = layer_count;
|
||||
|
||||
if (_mesa_is_desktop_gl(ctx) && !ctx->Extensions.ARB_ES2_compatibility) {
|
||||
/* Check that all DrawBuffers are present */
|
||||
|
|
|
@ -2994,7 +2994,13 @@ struct gl_framebuffer
|
|||
struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS];
|
||||
struct gl_renderbuffer *_ColorReadBuffer;
|
||||
|
||||
GLboolean Layered;
|
||||
/**
|
||||
* The number of layers in the framebuffer, or 0 if the framebuffer is not
|
||||
* layered. For cube maps, this value is 6. For cube map arrays, this
|
||||
* value is the "depth" value passed to TexImage3D (always a multiple of
|
||||
* 6).
|
||||
*/
|
||||
GLuint NumLayers;
|
||||
|
||||
/** Delete this framebuffer */
|
||||
void (*Delete)(struct gl_framebuffer *fb);
|
||||
|
|
Loading…
Reference in New Issue