aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2017-11-08 22:18:40 -0700
committerBrian Paul <[email protected]>2017-11-09 14:13:59 -0700
commitf8bae523d98953aa17105ecf12c5db499deb58ad (patch)
tree718d93771894324eaf2cbb94bbc8769dc2680080
parent366453f4d36e75bb4d8ec66feb5db7c92c748739 (diff)
mesa: s/GLint/gl_buffer_index/ for _ColorDrawBufferIndexes
Also fix local variable declarations and replace -1 with BUFFER_NONE. No Piglit changes. Reviewed-by: Charmaine Lee <[email protected]>
-rw-r--r--src/mesa/drivers/common/meta.c2
-rw-r--r--src/mesa/main/buffers.c16
-rw-r--r--src/mesa/main/clear.c9
-rw-r--r--src/mesa/main/framebuffer.c4
-rw-r--r--src/mesa/main/mtypes.h2
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c4
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c4
-rw-r--r--src/mesa/swrast/s_blit.c8
-rw-r--r--src/mesa/swrast/s_renderbuffer.c4
9 files changed, 27 insertions, 26 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index bae04bea516..1cc736cff1c 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -1655,7 +1655,7 @@ _mesa_meta_drawbuffers_and_colormask(struct gl_context *ctx, GLbitfield mask)
enums[0] = GL_NONE;
for (int i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
- int b = ctx->DrawBuffer->_ColorDrawBufferIndexes[i];
+ gl_buffer_index b = ctx->DrawBuffer->_ColorDrawBufferIndexes[i];
int colormask_idx = ctx->Extensions.EXT_draw_buffers2 ? i : 0;
if (b < 0 || !(mask & (1 << b)) || is_color_disabled(ctx, colormask_idx))
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 5c37f0f5376..d3640479f00 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -170,7 +170,7 @@ draw_buffer_enum_to_bitmask(const struct gl_context *ctx, GLenum buffer)
* Helper routine used by glReadBuffer.
* Given a GLenum naming a color buffer, return the index of the corresponding
* renderbuffer (a BUFFER_* value).
- * return -1 for an invalid buffer.
+ * return BUFFER_NONE for an invalid buffer.
*/
static gl_buffer_index
read_buffer_enum_to_index(const struct gl_context *ctx, GLenum buffer)
@@ -719,7 +719,7 @@ _mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
if (n > 0 && _mesa_bitcount(destMask[0]) > 1) {
GLuint count = 0, destMask0 = destMask[0];
while (destMask0) {
- const int bufIndex = u_bit_scan(&destMask0);
+ const gl_buffer_index bufIndex = u_bit_scan(&destMask0);
if (fb->_ColorDrawBufferIndexes[count] != bufIndex) {
updated_drawbuffers(ctx, fb);
fb->_ColorDrawBufferIndexes[count] = bufIndex;
@@ -733,7 +733,7 @@ _mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
GLuint count = 0;
for (buf = 0; buf < n; buf++ ) {
if (destMask[buf]) {
- GLint bufIndex = ffs(destMask[buf]) - 1;
+ gl_buffer_index bufIndex = ffs(destMask[buf]) - 1;
/* only one bit should be set in the destMask[buf] field */
assert(_mesa_bitcount(destMask[buf]) == 1);
if (fb->_ColorDrawBufferIndexes[buf] != bufIndex) {
@@ -743,9 +743,9 @@ _mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
count = buf + 1;
}
else {
- if (fb->_ColorDrawBufferIndexes[buf] != -1) {
+ if (fb->_ColorDrawBufferIndexes[buf] != BUFFER_NONE) {
updated_drawbuffers(ctx, fb);
- fb->_ColorDrawBufferIndexes[buf] = -1;
+ fb->_ColorDrawBufferIndexes[buf] = BUFFER_NONE;
}
}
fb->ColorDrawBuffer[buf] = buffers[buf];
@@ -753,11 +753,11 @@ _mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
fb->_NumColorDrawBuffers = count;
}
- /* set remaining outputs to -1 (GL_NONE) */
+ /* set remaining outputs to BUFFER_NONE */
for (buf = fb->_NumColorDrawBuffers; buf < ctx->Const.MaxDrawBuffers; buf++) {
- if (fb->_ColorDrawBufferIndexes[buf] != -1) {
+ if (fb->_ColorDrawBufferIndexes[buf] != BUFFER_NONE) {
updated_drawbuffers(ctx, fb);
- fb->_ColorDrawBufferIndexes[buf] = -1;
+ fb->_ColorDrawBufferIndexes[buf] = BUFFER_NONE;
}
}
for (buf = n; buf < ctx->Const.MaxDrawBuffers; buf++) {
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index c5e7f1346b0..be604426a0a 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -194,9 +194,9 @@ clear(struct gl_context *ctx, GLbitfield mask, bool no_error)
if (mask & GL_COLOR_BUFFER_BIT) {
GLuint i;
for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
- GLint buf = ctx->DrawBuffer->_ColorDrawBufferIndexes[i];
+ gl_buffer_index buf = ctx->DrawBuffer->_ColorDrawBufferIndexes[i];
- if (buf >= 0 && color_buffer_writes_enabled(ctx, i)) {
+ if (buf != BUFFER_NONE && color_buffer_writes_enabled(ctx, i)) {
bufferMask |= 1 << buf;
}
}
@@ -321,9 +321,10 @@ make_color_buffer_mask(struct gl_context *ctx, GLint drawbuffer)
break;
default:
{
- GLint buf = ctx->DrawBuffer->_ColorDrawBufferIndexes[drawbuffer];
+ gl_buffer_index buf =
+ ctx->DrawBuffer->_ColorDrawBufferIndexes[drawbuffer];
- if (buf >= 0 && att[buf].Renderbuffer) {
+ if (buf != BUFFER_NONE && att[buf].Renderbuffer) {
mask |= 1 << buf;
}
}
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 663c4034d4a..b17d7cbc94c 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -563,8 +563,8 @@ update_color_draw_buffers(struct gl_context *ctx, struct gl_framebuffer *fb)
fb->_ColorDrawBuffers[0] = NULL;
for (output = 0; output < fb->_NumColorDrawBuffers; output++) {
- GLint buf = fb->_ColorDrawBufferIndexes[output];
- if (buf >= 0) {
+ gl_buffer_index buf = fb->_ColorDrawBufferIndexes[output];
+ if (buf != BUFFER_NONE) {
fb->_ColorDrawBuffers[output] = fb->Attachment[buf].Renderbuffer;
}
else {
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index a8e2b39d40b..21e53db0902 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3483,7 +3483,7 @@ struct gl_framebuffer
/** Computed from ColorDraw/ReadBuffer above */
GLuint _NumColorDrawBuffers;
- GLint _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS]; /**< BUFFER_x or -1 */
+ gl_buffer_index _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS];
gl_buffer_index _ColorReadBufferIndex;
struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS];
struct gl_renderbuffer *_ColorReadBuffer;
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index cda9c71729c..f50f8442d55 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -412,9 +412,9 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
if (mask & BUFFER_BITS_COLOR) {
for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
- GLint b = ctx->DrawBuffer->_ColorDrawBufferIndexes[i];
+ gl_buffer_index b = ctx->DrawBuffer->_ColorDrawBufferIndexes[i];
- if (b >= 0 && mask & (1 << b)) {
+ if (b != BUFFER_NONE && mask & (1 << b)) {
struct gl_renderbuffer *rb
= ctx->DrawBuffer->Attachment[b].Renderbuffer;
struct st_renderbuffer *strb = st_renderbuffer(rb);
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index a7c286bcc52..e2303b4011f 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -721,9 +721,9 @@ st_DrawBuffers(struct gl_context *ctx, GLsizei count, const GLenum *buffers)
GLuint i;
/* add the renderbuffers on demand */
for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
- GLint idx = fb->_ColorDrawBufferIndexes[i];
+ gl_buffer_index idx = fb->_ColorDrawBufferIndexes[i];
- if (idx >= 0) {
+ if (idx != BUFFER_NONE) {
st_manager_add_color_renderbuffer(st, fb, idx);
}
}
diff --git a/src/mesa/swrast/s_blit.c b/src/mesa/swrast/s_blit.c
index 3e838a41d44..19fe8484eb9 100644
--- a/src/mesa/swrast/s_blit.c
+++ b/src/mesa/swrast/s_blit.c
@@ -198,8 +198,8 @@ blit_nearest(struct gl_context *ctx,
/* Blit to all the draw buffers */
for (i = 0; i < numDrawBuffers; i++) {
if (buffer == GL_COLOR_BUFFER_BIT) {
- int idx = drawFb->_ColorDrawBufferIndexes[i];
- if (idx == -1)
+ gl_buffer_index idx = drawFb->_ColorDrawBufferIndexes[i];
+ if (idx == BUFFER_NONE)
continue;
drawAtt = &drawFb->Attachment[idx];
drawRb = drawAtt->Renderbuffer;
@@ -569,12 +569,12 @@ blit_linear(struct gl_context *ctx,
}
for (i = 0; i < drawFb->_NumColorDrawBuffers; i++) {
- GLint idx = drawFb->_ColorDrawBufferIndexes[i];
+ gl_buffer_index idx = drawFb->_ColorDrawBufferIndexes[i];
struct gl_renderbuffer_attachment *drawAtt;
struct gl_renderbuffer *drawRb;
mesa_format drawFormat;
- if (idx == -1)
+ if (idx == BUFFER_NONE)
continue;
drawAtt = &drawFb->Attachment[idx];
diff --git a/src/mesa/swrast/s_renderbuffer.c b/src/mesa/swrast/s_renderbuffer.c
index 66a823def32..f76489c2005 100644
--- a/src/mesa/swrast/s_renderbuffer.c
+++ b/src/mesa/swrast/s_renderbuffer.c
@@ -659,7 +659,7 @@ _swrast_map_renderbuffers(struct gl_context *ctx)
}
for (buf = 0; buf < fb->_NumColorDrawBuffers; buf++) {
- if (fb->_ColorDrawBufferIndexes[buf] >= 0) {
+ if (fb->_ColorDrawBufferIndexes[buf] != BUFFER_NONE) {
map_attachment(ctx, fb, fb->_ColorDrawBufferIndexes[buf]);
find_renderbuffer_colortype(fb->_ColorDrawBuffers[buf]);
}
@@ -690,7 +690,7 @@ _swrast_unmap_renderbuffers(struct gl_context *ctx)
}
for (buf = 0; buf < fb->_NumColorDrawBuffers; buf++) {
- if (fb->_ColorDrawBufferIndexes[buf] >= 0) {
+ if (fb->_ColorDrawBufferIndexes[buf] != BUFFER_NONE) {
unmap_attachment(ctx, fb, fb->_ColorDrawBufferIndexes[buf]);
}
}