X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Faccum.c;h=2b15b6ee0d3a6bea148036bd96054f44e3739f6d;hb=167f6a33fa7be914f4b5171eeeb82bc5e01255f9;hp=421fe6cc5abc782d7819bfc21a7141ca96e2d4e6;hpb=3998cfa933dcd9134b75d9f0ae2c9cfcd6f2ee45;p=mesa.git diff --git a/src/mesa/main/accum.c b/src/mesa/main/accum.c index 421fe6cc5ab..2b15b6ee0d3 100644 --- a/src/mesa/main/accum.c +++ b/src/mesa/main/accum.c @@ -28,6 +28,7 @@ #include "context.h" #include "format_unpack.h" #include "format_pack.h" +#include "framebuffer.h" #include "imports.h" #include "macros.h" #include "state.h" @@ -53,57 +54,6 @@ _mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) } -void GLAPIENTRY -_mesa_Accum( GLenum op, GLfloat value ) -{ - GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - - switch (op) { - case GL_ADD: - case GL_MULT: - case GL_ACCUM: - case GL_LOAD: - case GL_RETURN: - /* OK */ - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glAccum(op)"); - return; - } - - if (ctx->DrawBuffer->Visual.haveAccumBuffer == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glAccum(no accum buffer)"); - return; - } - - if (ctx->DrawBuffer != ctx->ReadBuffer) { - /* See GLX_SGI_make_current_read or WGL_ARB_make_current_read, - * or GL_EXT_framebuffer_blit. - */ - _mesa_error(ctx, GL_INVALID_OPERATION, - "glAccum(different read/draw buffers)"); - return; - } - - if (ctx->NewState) - _mesa_update_state(ctx); - - if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { - _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, - "glAccum(incomplete framebuffer)"); - return; - } - - if (ctx->RasterDiscard) - return; - - if (ctx->RenderMode == GL_RENDER) { - _mesa_accum(ctx, op, value); - } -} - - /** * Clear the accumulation buffer by mapping the renderbuffer and * writing the clear color to it. Called by the driver's implementation @@ -124,6 +74,8 @@ _mesa_clear_accum_buffer(struct gl_context *ctx) if (!accRb) return; /* missing accum buffer, not an error */ + _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer); + /* bounds, with scissor */ x = ctx->DrawBuffer->_Xmin; y = ctx->DrawBuffer->_Ymin; @@ -138,7 +90,7 @@ _mesa_clear_accum_buffer(struct gl_context *ctx) return; } - if (accRb->Format == MESA_FORMAT_SIGNED_RGBA_16) { + if (accRb->Format == MESA_FORMAT_RGBA_SNORM16) { const GLshort clearR = FLOAT_TO_SHORT(ctx->Accum.ClearColor[0]); const GLshort clearG = FLOAT_TO_SHORT(ctx->Accum.ClearColor[1]); const GLshort clearB = FLOAT_TO_SHORT(ctx->Accum.ClearColor[2]); @@ -193,7 +145,7 @@ accum_scale_or_bias(struct gl_context *ctx, GLfloat value, return; } - if (accRb->Format == MESA_FORMAT_SIGNED_RGBA_16) { + if (accRb->Format == MESA_FORMAT_RGBA_SNORM16) { const GLshort incr = (GLshort) (value * 32767.0f); GLint i, j; if (bias) { @@ -271,7 +223,7 @@ accum_or_load(struct gl_context *ctx, GLfloat value, return; } - if (accRb->Format == MESA_FORMAT_SIGNED_RGBA_16) { + if (accRb->Format == MESA_FORMAT_RGBA_SNORM16) { const GLfloat scale = value * 32767.0f; GLint i, j; GLfloat (*rgba)[4]; @@ -363,7 +315,7 @@ accum_return(struct gl_context *ctx, GLfloat value, continue; } - if (accRb->Format == MESA_FORMAT_SIGNED_RGBA_16) { + if (accRb->Format == MESA_FORMAT_RGBA_SNORM16) { const GLfloat scale = value / 32767.0f; GLint i, j; GLfloat (*rgba)[4], (*dest)[4]; @@ -436,8 +388,8 @@ accum_return(struct gl_context *ctx, GLfloat value, * signed 16-bit color channels could implement hardware accumulation * operations, but no driver does so at this time. */ -void -_mesa_accum(struct gl_context *ctx, GLenum op, GLfloat value) +static void +accum(struct gl_context *ctx, GLenum op, GLfloat value) { GLint xpos, ypos, width, height; @@ -449,6 +401,8 @@ _mesa_accum(struct gl_context *ctx, GLenum op, GLfloat value) if (!_mesa_check_conditional_render(ctx)) return; + _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer); + xpos = ctx->DrawBuffer->_Xmin; ypos = ctx->DrawBuffer->_Ymin; width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; @@ -477,7 +431,7 @@ _mesa_accum(struct gl_context *ctx, GLenum op, GLfloat value) accum_return(ctx, value, xpos, ypos, width, height); break; default: - _mesa_problem(ctx, "invalid mode in _mesa_accum()"); + unreachable("invalid mode in _mesa_Accum()"); break; } } @@ -489,3 +443,54 @@ _mesa_init_accum( struct gl_context *ctx ) /* Accumulate buffer group */ ASSIGN_4V( ctx->Accum.ClearColor, 0.0, 0.0, 0.0, 0.0 ); } + + +void GLAPIENTRY +_mesa_Accum( GLenum op, GLfloat value ) +{ + GET_CURRENT_CONTEXT(ctx); + FLUSH_VERTICES(ctx, 0); + + switch (op) { + case GL_ADD: + case GL_MULT: + case GL_ACCUM: + case GL_LOAD: + case GL_RETURN: + /* OK */ + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glAccum(op)"); + return; + } + + if (ctx->DrawBuffer->Visual.haveAccumBuffer == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glAccum(no accum buffer)"); + return; + } + + if (ctx->DrawBuffer != ctx->ReadBuffer) { + /* See GLX_SGI_make_current_read or WGL_ARB_make_current_read, + * or GL_EXT_framebuffer_blit. + */ + _mesa_error(ctx, GL_INVALID_OPERATION, + "glAccum(different read/draw buffers)"); + return; + } + + if (ctx->NewState) + _mesa_update_state(ctx); + + if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { + _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT, + "glAccum(incomplete framebuffer)"); + return; + } + + if (ctx->RasterDiscard) + return; + + if (ctx->RenderMode == GL_RENDER) { + accum(ctx, op, value); + } +}