diff options
Diffstat (limited to 'mesalib/src/mesa')
31 files changed, 137 insertions, 334 deletions
diff --git a/mesalib/src/mesa/drivers/common/driverfuncs.c b/mesalib/src/mesa/drivers/common/driverfuncs.c index 016c0e80f..5faa98af1 100644 --- a/mesalib/src/mesa/drivers/common/driverfuncs.c +++ b/mesalib/src/mesa/drivers/common/driverfuncs.c @@ -75,7 +75,6 @@ _mesa_init_driver_functions(struct dd_function_table *driver) driver->GetString = NULL; /* REQUIRED! */ driver->UpdateState = NULL; /* REQUIRED! */ - driver->GetBufferSize = NULL; /* REQUIRED! */ driver->ResizeBuffers = _mesa_resize_framebuffer; driver->Finish = NULL; diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am b/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am index b545f37de..ad7887d06 100644 --- a/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am +++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am @@ -66,7 +66,7 @@ options.h: t_options.h $(MOS) # Update .mo files from the corresponding .po files. %/LC_MESSAGES/options.mo: %.po - @mo="$@" \ + @mo="$@"; \ lang=$${mo%%/*}; \ echo "Updating ($$lang) $@ from $?."; \ mkdir -p $$lang/LC_MESSAGES; \ diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c index f72db1029..15681fce2 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c +++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c @@ -647,7 +647,6 @@ swrast_init_driver_functions(struct dd_function_table *driver) { driver->GetString = get_string; driver->UpdateState = update_state; - driver->GetBufferSize = NULL; driver->Viewport = viewport; driver->ChooseTextureFormat = swrastChooseTextureFormat; driver->MapRenderbuffer = swrast_map_renderbuffer; diff --git a/mesalib/src/mesa/drivers/windows/gdi/wmesa.c b/mesalib/src/mesa/drivers/windows/gdi/wmesa.c index 35ec65ac3..ef791ab2f 100644 --- a/mesalib/src/mesa/drivers/windows/gdi/wmesa.c +++ b/mesalib/src/mesa/drivers/windows/gdi/wmesa.c @@ -605,7 +605,6 @@ WMesaContext WMesaCreateContext(HDC hDC, _mesa_init_driver_functions(&functions); functions.GetString = wmesa_get_string; functions.UpdateState = wmesa_update_state; - functions.GetBufferSize = wmesa_get_buffer_size; functions.Flush = wmesa_flush; functions.Clear = clear; functions.ResizeBuffers = wmesa_resize_buffers; diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c index 9358e699c..ca617f744 100644 --- a/mesalib/src/mesa/main/attrib.c +++ b/mesalib/src/mesa/main/attrib.c @@ -1045,8 +1045,6 @@ _mesa_PopAttrib(void) _mesa_Hint(GL_LINE_SMOOTH_HINT, hint->LineSmooth); _mesa_Hint(GL_POLYGON_SMOOTH_HINT, hint->PolygonSmooth); _mesa_Hint(GL_FOG_HINT, hint->Fog); - _mesa_Hint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT, - hint->ClipVolumeClipping); _mesa_Hint(GL_TEXTURE_COMPRESSION_HINT_ARB, hint->TextureCompression); } diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c index c59f755c6..5ad04cc99 100644 --- a/mesalib/src/mesa/main/context.c +++ b/mesalib/src/mesa/main/context.c @@ -1388,25 +1388,6 @@ check_compatible(const struct gl_context *ctx, /** - * Do one-time initialization for the given framebuffer. Specifically, - * ask the driver for the window's current size and update the framebuffer - * object to match. - * Really, the device driver should totally take care of this. - */ -static void -initialize_framebuffer_size(struct gl_context *ctx, struct gl_framebuffer *fb) -{ - GLuint width, height; - if (ctx->Driver.GetBufferSize) { - ctx->Driver.GetBufferSize(fb, &width, &height); - if (ctx->Driver.ResizeBuffers) - ctx->Driver.ResizeBuffers(ctx, fb, width, height); - fb->Initialized = GL_TRUE; - } -} - - -/** * Check if the viewport/scissor size has not yet been initialized. * Initialize the size if the given width and height are non-zero. */ @@ -1508,32 +1489,6 @@ _mesa_make_current( struct gl_context *newCtx, */ newCtx->NewState |= _NEW_BUFFERS; -#if 1 - /* We want to get rid of these lines: */ - if (!drawBuffer->Initialized) { - initialize_framebuffer_size(newCtx, drawBuffer); - } - if (readBuffer != drawBuffer && !readBuffer->Initialized) { - initialize_framebuffer_size(newCtx, readBuffer); - } - - _mesa_resizebuffers(newCtx); -#else - /* We want the drawBuffer and readBuffer to be initialized by - * the driver. - * This generally means the Width and Height match the actual - * window size and the renderbuffers (both hardware and software - * based) are allocated to match. The later can generally be - * done with a call to _mesa_resize_framebuffer(). - * - * It's theoretically possible for a buffer to have zero width - * or height, but for now, assert check that the driver did what's - * expected of it. - */ - ASSERT(drawBuffer->Width > 0); - ASSERT(drawBuffer->Height > 0); -#endif - if (drawBuffer) { _mesa_check_init_viewport(newCtx, drawBuffer->Width, drawBuffer->Height); diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h index e2519780a..c1d9b2c95 100644 --- a/mesalib/src/mesa/main/dd.h +++ b/mesalib/src/mesa/main/dd.h @@ -93,15 +93,6 @@ struct dd_function_table { void (*UpdateState)( struct gl_context *ctx, GLbitfield new_state ); /** - * Get the width and height of the named buffer/window. - * - * Mesa uses this to determine when the driver's window size has changed. - * XXX OBSOLETE: this function will be removed in the future. - */ - void (*GetBufferSize)( struct gl_framebuffer *buffer, - GLuint *width, GLuint *height ); - - /** * Resize the given framebuffer to the given size. * XXX OBSOLETE: this function will be removed in the future. */ diff --git a/mesalib/src/mesa/main/errors.c b/mesalib/src/mesa/main/errors.c index cc652bac8..465420766 100644 --- a/mesalib/src/mesa/main/errors.c +++ b/mesalib/src/mesa/main/errors.c @@ -659,11 +659,11 @@ _mesa_DebugMessageControlARB(GLenum gl_source, GLenum gl_type, } void GLAPIENTRY -_mesa_DebugMessageCallbackARB(GLDEBUGPROCARB callback, const GLvoid *userParam) +_mesa_DebugMessageCallbackARB(GLDEBUGPROCARB callback, GLvoid *userParam) { GET_CURRENT_CONTEXT(ctx); ctx->Debug.Callback = callback; - ctx->Debug.CallbackData = (void *) userParam; + ctx->Debug.CallbackData = userParam; } void diff --git a/mesalib/src/mesa/main/errors.h b/mesalib/src/mesa/main/errors.h index 7e7503aa9..4b376fb60 100644 --- a/mesalib/src/mesa/main/errors.h +++ b/mesalib/src/mesa/main/errors.h @@ -101,7 +101,7 @@ _mesa_DebugMessageControlARB(GLenum source, GLenum type, GLenum severity, GLboolean enabled); void GLAPIENTRY _mesa_DebugMessageCallbackARB(GLDEBUGPROCARB callback, - const GLvoid *userParam); + GLvoid *userParam); #ifdef __cplusplus } diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c index fc6fbadec..2ba4475c9 100644 --- a/mesalib/src/mesa/main/extensions.c +++ b/mesalib/src/mesa/main/extensions.c @@ -174,7 +174,6 @@ static const struct extension extension_table[] = { { "GL_EXT_discard_framebuffer", o(EXT_framebuffer_object), ES1 | ES2, 2009 }, { "GL_EXT_blend_minmax", o(EXT_blend_minmax), GLL | ES1 | ES2, 1995 }, { "GL_EXT_blend_subtract", o(dummy_true), GLL, 1995 }, - { "GL_EXT_clip_volume_hint", o(EXT_clip_volume_hint), GL, 1996 }, { "GL_EXT_compiled_vertex_array", o(dummy_true), GLL, 1996 }, { "GL_EXT_copy_texture", o(dummy_true), GLL, 1995 }, { "GL_EXT_depth_bounds_test", o(EXT_depth_bounds_test), GL, 2002 }, diff --git a/mesalib/src/mesa/main/ff_fragment_shader.cpp b/mesalib/src/mesa/main/ff_fragment_shader.cpp index d162da8db..86317efcd 100644 --- a/mesalib/src/mesa/main/ff_fragment_shader.cpp +++ b/mesalib/src/mesa/main/ff_fragment_shader.cpp @@ -51,7 +51,6 @@ extern "C" { #include "../glsl/glsl_symbol_table.h" #include "../glsl/glsl_parser_extras.h" #include "../glsl/ir_optimization.h" -#include "../glsl/ir_print_visitor.h" #include "../program/ir_to_mesa.h" using namespace ir_builder; diff --git a/mesalib/src/mesa/main/framebuffer.c b/mesalib/src/mesa/main/framebuffer.c index 1906a8a55..d28882ac4 100644 --- a/mesalib/src/mesa/main/framebuffer.c +++ b/mesalib/src/mesa/main/framebuffer.c @@ -319,81 +319,12 @@ _mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb, } } - - -/** - * XXX THIS IS OBSOLETE - drivers should take care of detecting window - * size changes and act accordingly, likely calling _mesa_resize_framebuffer(). - * - * GL_MESA_resize_buffers extension. - * - * When this function is called, we'll ask the window system how large - * the current window is. If it's a new size, we'll call the driver's - * ResizeBuffers function. The driver will then resize its color buffers - * as needed, and maybe call the swrast's routine for reallocating - * swrast-managed depth/stencil/accum/etc buffers. - * \note This function should only be called through the GL API, not - * from device drivers (as was done in the past). - */ -void -_mesa_resizebuffers( struct gl_context *ctx ) -{ - FLUSH_VERTICES(ctx, 0); - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glResizeBuffersMESA\n"); - - if (!ctx->Driver.GetBufferSize) { - return; - } - - if (ctx->WinSysDrawBuffer) { - GLuint newWidth, newHeight; - struct gl_framebuffer *buffer = ctx->WinSysDrawBuffer; - - assert(_mesa_is_winsys_fbo(buffer)); - - /* ask device driver for size of output buffer */ - ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight ); - - /* see if size of device driver's color buffer (window) has changed */ - if (buffer->Width != newWidth || buffer->Height != newHeight) { - if (ctx->Driver.ResizeBuffers) - ctx->Driver.ResizeBuffers(ctx, buffer, newWidth, newHeight ); - } - } - - if (ctx->WinSysReadBuffer - && ctx->WinSysReadBuffer != ctx->WinSysDrawBuffer) { - GLuint newWidth, newHeight; - struct gl_framebuffer *buffer = ctx->WinSysReadBuffer; - - assert(_mesa_is_winsys_fbo(buffer)); - - /* ask device driver for size of read buffer */ - ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight ); - - /* see if size of device driver's color buffer (window) has changed */ - if (buffer->Width != newWidth || buffer->Height != newHeight) { - if (ctx->Driver.ResizeBuffers) - ctx->Driver.ResizeBuffers(ctx, buffer, newWidth, newHeight ); - } - } - - ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */ -} - - /* * XXX THIS IS OBSOLETE */ void GLAPIENTRY _mesa_ResizeBuffersMESA( void ) { - GET_CURRENT_CONTEXT(ctx); - - if (ctx->Extensions.MESA_resize_buffers) - _mesa_resizebuffers( ctx ); } diff --git a/mesalib/src/mesa/main/hint.c b/mesalib/src/mesa/main/hint.c index 6d3e58d58..3e056ebaf 100644 --- a/mesalib/src/mesa/main/hint.c +++ b/mesalib/src/mesa/main/hint.c @@ -90,16 +90,6 @@ _mesa_Hint( GLenum target, GLenum mode ) ctx->Hint.PolygonSmooth = mode; break; - /* GL_EXT_clip_volume_hint */ - case GL_CLIP_VOLUME_CLIPPING_HINT_EXT: - if (ctx->API != API_OPENGL_COMPAT) - goto invalid_target; - if (ctx->Hint.ClipVolumeClipping == mode) - return; - FLUSH_VERTICES(ctx, _NEW_HINT); - ctx->Hint.ClipVolumeClipping = mode; - break; - /* GL_ARB_texture_compression */ case GL_TEXTURE_COMPRESSION_HINT_ARB: if (!_mesa_is_desktop_gl(ctx)) @@ -158,7 +148,6 @@ void _mesa_init_hint( struct gl_context * ctx ) ctx->Hint.LineSmooth = GL_DONT_CARE; ctx->Hint.PolygonSmooth = GL_DONT_CARE; ctx->Hint.Fog = GL_DONT_CARE; - ctx->Hint.ClipVolumeClipping = GL_DONT_CARE; ctx->Hint.TextureCompression = GL_DONT_CARE; ctx->Hint.GenerateMipmap = GL_DONT_CARE; ctx->Hint.FragmentShaderDerivative = GL_DONT_CARE; diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index 0002da5c0..df2d20b3a 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -794,7 +794,6 @@ struct gl_hint_attrib GLenum LineSmooth; GLenum PolygonSmooth; GLenum Fog; - GLenum ClipVolumeClipping; /**< GL_EXT_clip_volume_hint */ GLenum TextureCompression; /**< GL_ARB_texture_compression */ GLenum GenerateMipmap; /**< GL_SGIS_generate_mipmap */ GLenum FragmentShaderDerivative; /**< GL_ARB_fragment_shader */ @@ -2680,8 +2679,6 @@ struct gl_framebuffer */ struct gl_config Visual; - GLboolean Initialized; - GLuint Width, Height; /**< size of frame buffer in pixels */ /** \name Drawing bounds (Intersection of buffer size and scissor box) */ @@ -3055,7 +3052,6 @@ struct gl_extensions GLboolean EXT_blend_equation_separate; GLboolean EXT_blend_func_separate; GLboolean EXT_blend_minmax; - GLboolean EXT_clip_volume_hint; GLboolean EXT_depth_bounds_test; GLboolean EXT_draw_buffers2; GLboolean EXT_fog_coord; diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c index 8cb02760b..4cc0357b1 100644 --- a/mesalib/src/mesa/main/shaderapi.c +++ b/mesalib/src/mesa/main/shaderapi.c @@ -48,11 +48,14 @@ #include "main/transformfeedback.h" #include "main/uniforms.h" #include "program/program.h" +#include "program/prog_print.h" #include "program/prog_parameter.h" #include "ralloc.h" #include <stdbool.h> #include "../glsl/glsl_parser_extras.h" +#include "../glsl/ir.h" #include "../glsl/ir_uniform.h" +#include "../glsl/program.h" /** Define this to enable shader substitution (see below) */ #define SHADER_SUBST 0 @@ -743,10 +746,42 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj) /* set default pragma state for shader */ sh->Pragmas = options->DefaultPragmas; - /* this call will set the sh->CompileStatus field to indicate if - * compilation was successful. - */ - _mesa_glsl_compile_shader(ctx, sh); + if (!sh->Source) { + /* If the user called glCompileShader without first calling + * glShaderSource, we should fail to compile, but not raise a GL_ERROR. + */ + sh->CompileStatus = GL_FALSE; + } else { + if (ctx->Shader.Flags & GLSL_DUMP) { + printf("GLSL source for %s shader %d:\n", + _mesa_glsl_shader_target_name(sh->Type), sh->Name); + printf("%s\n", sh->Source); + } + + /* this call will set the shader->CompileStatus field to indicate if + * compilation was successful. + */ + _mesa_glsl_compile_shader(ctx, sh, false, false); + + if (ctx->Shader.Flags & GLSL_LOG) { + _mesa_write_shader_to_file(sh); + } + + if (ctx->Shader.Flags & GLSL_DUMP) { + if (sh->CompileStatus) { + printf("GLSL IR for shader %d:\n", sh->Name); + _mesa_print_ir(sh->ir, NULL); + printf("\n\n"); + } else { + printf("GLSL shader %d failed to compile.\n", sh->Name); + } + if (sh->InfoLog && sh->InfoLog[0] != 0) { + printf("GLSL shader %d info log:\n", sh->Name); + printf("%s\n", sh->InfoLog); + } + } + + } if (sh->CompileStatus == GL_FALSE && (ctx->Shader.Flags & GLSL_REPORT_ERRORS)) { @@ -816,21 +851,8 @@ print_shader_info(const struct gl_shader_program *shProg) printf("Mesa: glUseProgram(%u)\n", shProg->Name); for (i = 0; i < shProg->NumShaders; i++) { - const char *s; - switch (shProg->Shaders[i]->Type) { - case GL_VERTEX_SHADER: - s = "vertex"; - break; - case GL_FRAGMENT_SHADER: - s = "fragment"; - break; - case GL_GEOMETRY_SHADER: - s = "geometry"; - break; - default: - s = ""; - } - printf(" %s shader %u, checksum %u\n", s, + printf(" %s shader %u, checksum %u\n", + _mesa_glsl_shader_target_name(shProg->Shaders[i]->Type), shProg->Shaders[i]->Name, shProg->Shaders[i]->SourceChecksum); } diff --git a/mesalib/src/mesa/main/uniform_query.cpp b/mesalib/src/mesa/main/uniform_query.cpp index 296f80f17..3c460042e 100644 --- a/mesalib/src/mesa/main/uniform_query.cpp +++ b/mesalib/src/mesa/main/uniform_query.cpp @@ -33,6 +33,7 @@ #include "program/hash_table.h" #include "../glsl/program.h" #include "../glsl/ir_uniform.h" +#include "../glsl/glsl_parser_extras.h" #include "main/shaderapi.h" #include "main/shaderobj.h" #include "uniforms.h" @@ -434,12 +435,6 @@ log_uniform(const void *values, enum glsl_base_type basicType, static void log_program_parameters(const struct gl_shader_program *shProg) { - static const char *stages[] = { - "vertex", "fragment", "geometry" - }; - - assert(Elements(stages) == MESA_SHADER_TYPES); - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { if (shProg->_LinkedShaders[i] == NULL) continue; @@ -447,7 +442,7 @@ log_program_parameters(const struct gl_shader_program *shProg) const struct gl_program *const prog = shProg->_LinkedShaders[i]->Program; printf("Program %d %s shader parameters:\n", - shProg->Name, stages[i]); + shProg->Name, _mesa_glsl_shader_target_name(prog->Target)); for (unsigned j = 0; j < prog->Parameters->NumParameters; j++) { printf("%s: %p %f %f %f %f\n", prog->Parameters->Parameters[j].Name, diff --git a/mesalib/src/mesa/main/uniforms.h b/mesalib/src/mesa/main/uniforms.h index 14fe26d5f..92239176e 100644 --- a/mesalib/src/mesa/main/uniforms.h +++ b/mesalib/src/mesa/main/uniforms.h @@ -272,7 +272,7 @@ static inline GLint _mesa_uniform_merge_location_offset(const struct gl_shader_program *prog, unsigned base_location, unsigned offset) { - assert(prog->UniformLocationBaseScale >= 0); + assert(prog->UniformLocationBaseScale >= 1); assert(offset < prog->UniformLocationBaseScale); return (base_location * prog->UniformLocationBaseScale) + offset; } diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp index a5b6699c2..35a9b8437 100644 --- a/mesalib/src/mesa/program/ir_to_mesa.cpp +++ b/mesalib/src/mesa/program/ir_to_mesa.cpp @@ -33,7 +33,6 @@ #include "main/compiler.h" #include "ir.h" #include "ir_visitor.h" -#include "ir_print_visitor.h" #include "ir_expression_flattening.h" #include "ir_uniform.h" #include "glsl_types.h" @@ -1057,9 +1056,9 @@ ir_to_mesa_visitor::emit_swz(ir_expression *ir) this->result.file = PROGRAM_UNDEFINED; deref->accept(this); if (this->result.file == PROGRAM_UNDEFINED) { - ir_print_visitor v; printf("Failed to get tree for expression operand:\n"); - deref->accept(&v); + deref->print(); + printf("\n"); exit(1); } @@ -1129,9 +1128,9 @@ ir_to_mesa_visitor::visit(ir_expression *ir) this->result.file = PROGRAM_UNDEFINED; ir->operands[operand]->accept(this); if (this->result.file == PROGRAM_UNDEFINED) { - ir_print_visitor v; printf("Failed to get tree for expression operand:\n"); - ir->operands[operand]->accept(&v); + ir->operands[operand]->print(); + printf("\n"); exit(1); } op[operand] = this->result; @@ -2811,22 +2810,19 @@ get_mesa_program(struct gl_context *ctx, int i; struct gl_program *prog; GLenum target; - const char *target_string; + const char *target_string = _mesa_glsl_shader_target_name(shader->Type); struct gl_shader_compiler_options *options = &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(shader->Type)]; switch (shader->Type) { case GL_VERTEX_SHADER: target = GL_VERTEX_PROGRAM_ARB; - target_string = "vertex"; break; case GL_FRAGMENT_SHADER: target = GL_FRAGMENT_PROGRAM_ARB; - target_string = "fragment"; break; case GL_GEOMETRY_SHADER: target = GL_GEOMETRY_PROGRAM_NV; - target_string = "geometry"; break; default: assert(!"should not be reached"); @@ -3101,99 +3097,6 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) return prog->LinkStatus; } - -/** - * Compile a GLSL shader. Called via glCompileShader(). - */ -void -_mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader) -{ - struct _mesa_glsl_parse_state *state = - new(shader) _mesa_glsl_parse_state(ctx, shader->Type, shader); - - const char *source = shader->Source; - /* Check if the user called glCompileShader without first calling - * glShaderSource. This should fail to compile, but not raise a GL_ERROR. - */ - if (source == NULL) { - shader->CompileStatus = GL_FALSE; - return; - } - - state->error = glcpp_preprocess(state, &source, &state->info_log, - &ctx->Extensions, ctx); - - if (ctx->Shader.Flags & GLSL_DUMP) { - printf("GLSL source for %s shader %d:\n", - _mesa_glsl_shader_target_name(state->target), shader->Name); - printf("%s\n", shader->Source); - } - - if (!state->error) { - _mesa_glsl_lexer_ctor(state, source); - _mesa_glsl_parse(state); - _mesa_glsl_lexer_dtor(state); - } - - ralloc_free(shader->ir); - shader->ir = new(shader) exec_list; - if (!state->error && !state->translation_unit.is_empty()) - _mesa_ast_to_hir(shader->ir, state); - - if (!state->error && !shader->ir->is_empty()) { - validate_ir_tree(shader->ir); - struct gl_shader_compiler_options *options = - &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(shader->Type)]; - - /* Do some optimization at compile time to reduce shader IR size - * and reduce later work if the same shader is linked multiple times - */ - while (do_common_optimization(shader->ir, false, false, 32, options)) - ; - - validate_ir_tree(shader->ir); - } - - shader->symbols = state->symbols; - - shader->CompileStatus = !state->error; - shader->InfoLog = state->info_log; - shader->Version = state->language_version; - memcpy(shader->builtins_to_link, state->builtins_to_link, - sizeof(shader->builtins_to_link[0]) * state->num_builtins_to_link); - shader->num_builtins_to_link = state->num_builtins_to_link; - - if (ctx->Shader.Flags & GLSL_LOG) { - _mesa_write_shader_to_file(shader); - } - - if (ctx->Shader.Flags & GLSL_DUMP) { - if (shader->CompileStatus) { - printf("GLSL IR for shader %d:\n", shader->Name); - _mesa_print_ir(shader->ir, NULL); - printf("\n\n"); - } else { - printf("GLSL shader %d failed to compile.\n", shader->Name); - } - if (shader->InfoLog && shader->InfoLog[0] != 0) { - printf("GLSL shader %d info log:\n", shader->Name); - printf("%s\n", shader->InfoLog); - } - } - - if (shader->UniformBlocks) - ralloc_free(shader->UniformBlocks); - shader->NumUniformBlocks = state->num_uniform_blocks; - shader->UniformBlocks = state->uniform_blocks; - ralloc_steal(shader, shader->UniformBlocks); - - /* Retain any live IR, but trash the rest. */ - reparent_ir(shader->ir, shader->ir); - - ralloc_free(state); -} - - /** * Link a GLSL shader program. Called via glLinkProgram(). */ diff --git a/mesalib/src/mesa/program/ir_to_mesa.h b/mesalib/src/mesa/program/ir_to_mesa.h index aa053d9c8..2488a4582 100644 --- a/mesalib/src/mesa/program/ir_to_mesa.h +++ b/mesalib/src/mesa/program/ir_to_mesa.h @@ -33,7 +33,6 @@ struct gl_context; struct gl_shader; struct gl_shader_program; -void _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *sh); void _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog); GLboolean _mesa_ir_compile_shader(struct gl_context *ctx, struct gl_shader *shader); GLboolean _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog); diff --git a/mesalib/src/mesa/program/register_allocate.c b/mesalib/src/mesa/program/register_allocate.c index 16739fd39..4eed0b5aa 100644 --- a/mesalib/src/mesa/program/register_allocate.c +++ b/mesalib/src/mesa/program/register_allocate.c @@ -157,6 +157,16 @@ struct ra_graph { unsigned int *stack; unsigned int stack_count; + + /** + * Tracks the start of the set of optimistically-colored registers in the + * stack. + * + * Along with any registers not in the stack (if one called ra_simplify() + * and didn't do optimistic coloring), these need to be considered for + * spilling. + */ + unsigned int stack_optimistic_start; }; /** @@ -509,6 +519,7 @@ ra_optimistic_color(struct ra_graph *g) { unsigned int i; + g->stack_optimistic_start = g->stack_count; for (i = 0; i < g->count; i++) { if (g->nodes[i].in_stack || g->nodes[i].reg != NO_REG) continue; @@ -587,8 +598,16 @@ ra_get_best_spill_node(struct ra_graph *g) { unsigned int best_node = -1; float best_benefit = 0.0; - unsigned int n; + unsigned int n, i; + /* For any registers not in the stack to be colored, consider them for + * spilling. This will mostly collect nodes that were being optimistally + * colored as part of ra_allocate_no_spills() if we didn't successfully + * optimistically color. + * + * It also includes nodes not trivially colorable by ra_simplify() if it + * was used directly instead of as part of ra_allocate_no_spills(). + */ for (n = 0; n < g->count; n++) { float cost = g->nodes[n].spill_cost; float benefit; @@ -596,10 +615,6 @@ ra_get_best_spill_node(struct ra_graph *g) if (cost <= 0.0) continue; - /* Only consider registers for spilling if they are still in the - * interference graph (those on the stack have already been proven to be - * allocatable without spilling). - */ if (g->nodes[n].in_stack) continue; @@ -611,6 +626,26 @@ ra_get_best_spill_node(struct ra_graph *g) } } + /* Also consider spilling any nodes that were set up to be optimistically + * colored that we couldn't manage to color in ra_select(). + */ + for (i = g->stack_optimistic_start; i < g->stack_count; i++) { + float cost, benefit; + + n = g->stack[i]; + cost = g->nodes[n].spill_cost; + + if (cost <= 0.0) + continue; + + benefit = ra_get_spill_benefit(g, n); + + if (benefit / cost > best_benefit) { + best_benefit = benefit / cost; + best_node = n; + } + } + return best_node; } diff --git a/mesalib/src/mesa/state_tracker/st_atom_constbuf.c b/mesalib/src/mesa/state_tracker/st_atom_constbuf.c index 27a910b5f..723ab561c 100644 --- a/mesalib/src/mesa/state_tracker/st_atom_constbuf.c +++ b/mesalib/src/mesa/state_tracker/st_atom_constbuf.c @@ -205,7 +205,7 @@ static void st_bind_ubos(struct st_context *st, * Take the minimum just to be sure. */ if (!binding->AutomaticSize) - cb.buffer_size = MIN2(cb.buffer_size, binding->Size); + cb.buffer_size = MIN2(cb.buffer_size, (unsigned) binding->Size); } else { cb.buffer_offset = 0; diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c index b8e2fad25..8da664afb 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_clear.c +++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c @@ -346,8 +346,8 @@ is_scissor_enabled(struct gl_context *ctx, struct gl_renderbuffer *rb) return ctx->Scissor.Enabled && (ctx->Scissor.X > 0 || ctx->Scissor.Y > 0 || - ctx->Scissor.Width < rb->Width || - ctx->Scissor.Height < rb->Height); + (unsigned) ctx->Scissor.Width < rb->Width || + (unsigned) ctx->Scissor.Height < rb->Height); } diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.h b/mesalib/src/mesa/state_tracker/st_cb_fbo.h index 461dbe985..f335c371b 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_fbo.h +++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.h @@ -59,7 +59,7 @@ struct st_renderbuffer void *data; struct st_texture_object *rtt; /**< GL render to texture's texture */ - int rtt_level, rtt_face, rtt_slice; + unsigned rtt_level, rtt_face, rtt_slice; }; diff --git a/mesalib/src/mesa/state_tracker/st_cb_readpixels.c b/mesalib/src/mesa/state_tracker/st_cb_readpixels.c index 9fab113fa..b5df58c03 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_readpixels.c +++ b/mesalib/src/mesa/state_tracker/st_cb_readpixels.c @@ -208,7 +208,7 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y, const uint bytesPerRow = width * util_format_get_blocksize(dst_format); GLuint row; - for (row = 0; row < height; row++) { + for (row = 0; row < (unsigned) height; row++) { GLvoid *dest = _mesa_image_address3d(pack, pixels, width, height, format, type, 0, row, 0); diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c index 68c334ed8..c167744f4 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_texture.c +++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c @@ -734,7 +734,7 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims, const uint bytesPerRow = width * util_format_get_blocksize(src_format); GLuint row, slice; - for (slice = 0; slice < depth; slice++) { + for (slice = 0; slice < (unsigned) depth; slice++) { if (gl_target == GL_TEXTURE_1D_ARRAY) { /* 1D array textures. * We need to convert gallium coords to GL coords. @@ -747,7 +747,7 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims, else { ubyte *slice_map = map; - for (row = 0; row < height; row++) { + for (row = 0; row < (unsigned) height; row++) { GLvoid *src = _mesa_image_address3d(unpack, pixels, width, height, format, type, slice, row, 0); @@ -1625,7 +1625,7 @@ st_AllocTextureStorage(struct gl_context *ctx, GLuint ptWidth, ptHeight, ptDepth, ptLayers, bindings; enum pipe_format fmt; GLint level; - int num_samples = texImage->NumSamples; + GLuint num_samples = texImage->NumSamples; assert(levels > 0); diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c index 56f3a4a48..16d977fc9 100644 --- a/mesalib/src/mesa/state_tracker/st_format.c +++ b/mesalib/src/mesa/state_tracker/st_format.c @@ -55,21 +55,21 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) { switch (mesaFormat) { case MESA_FORMAT_RGBA8888: - return PIPE_FORMAT_A8B8G8R8_UNORM; + return PIPE_FORMAT_ABGR8888_UNORM; case MESA_FORMAT_RGBA8888_REV: - return PIPE_FORMAT_R8G8B8A8_UNORM; + return PIPE_FORMAT_RGBA8888_UNORM; case MESA_FORMAT_ARGB8888: - return PIPE_FORMAT_B8G8R8A8_UNORM; + return PIPE_FORMAT_BGRA8888_UNORM; case MESA_FORMAT_ARGB8888_REV: - return PIPE_FORMAT_A8R8G8B8_UNORM; + return PIPE_FORMAT_ARGB8888_UNORM; case MESA_FORMAT_RGBX8888: - return PIPE_FORMAT_X8B8G8R8_UNORM; + return PIPE_FORMAT_XBGR8888_UNORM; case MESA_FORMAT_RGBX8888_REV: - return PIPE_FORMAT_R8G8B8X8_UNORM; + return PIPE_FORMAT_RGBX8888_UNORM; case MESA_FORMAT_XRGB8888: - return PIPE_FORMAT_B8G8R8X8_UNORM; + return PIPE_FORMAT_BGRX8888_UNORM; case MESA_FORMAT_XRGB8888_REV: - return PIPE_FORMAT_X8R8G8B8_UNORM; + return PIPE_FORMAT_XRGB8888_UNORM; case MESA_FORMAT_ARGB1555: return PIPE_FORMAT_B5G5R5A1_UNORM; case MESA_FORMAT_ARGB4444: @@ -401,21 +401,21 @@ gl_format st_pipe_format_to_mesa_format(enum pipe_format format) { switch (format) { - case PIPE_FORMAT_A8B8G8R8_UNORM: + case PIPE_FORMAT_ABGR8888_UNORM: return MESA_FORMAT_RGBA8888; - case PIPE_FORMAT_R8G8B8A8_UNORM: + case PIPE_FORMAT_RGBA8888_UNORM: return MESA_FORMAT_RGBA8888_REV; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_BGRA8888_UNORM: return MESA_FORMAT_ARGB8888; - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_ARGB8888_UNORM: return MESA_FORMAT_ARGB8888_REV; - case PIPE_FORMAT_X8B8G8R8_UNORM: + case PIPE_FORMAT_XBGR8888_UNORM: return MESA_FORMAT_RGBX8888; - case PIPE_FORMAT_R8G8B8X8_UNORM: + case PIPE_FORMAT_RGBX8888_UNORM: return MESA_FORMAT_RGBX8888_REV; - case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_BGRX8888_UNORM: return MESA_FORMAT_XRGB8888; - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_XRGB8888_UNORM: return MESA_FORMAT_XRGB8888_REV; case PIPE_FORMAT_B5G5R5A1_UNORM: return MESA_FORMAT_ARGB1555; @@ -1521,12 +1521,12 @@ struct exact_format_mapping static const struct exact_format_mapping rgba8888_tbl[] = { - { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_A8B8G8R8_UNORM }, - { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_A8B8G8R8_UNORM }, - { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_R8G8B8A8_UNORM }, - { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_R8G8B8A8_UNORM }, - { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_A8R8G8B8_UNORM }, - { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_B8G8R8A8_UNORM }, + { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_ABGR8888_UNORM }, + { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_ABGR8888_UNORM }, + { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_RGBA8888_UNORM }, + { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_RGBA8888_UNORM }, + { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_ARGB8888_UNORM }, + { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_BGRA8888_UNORM }, { GL_RGBA, GL_UNSIGNED_BYTE, PIPE_FORMAT_R8G8B8A8_UNORM }, { GL_ABGR_EXT, GL_UNSIGNED_BYTE, PIPE_FORMAT_A8B8G8R8_UNORM }, { GL_BGRA, GL_UNSIGNED_BYTE, PIPE_FORMAT_B8G8R8A8_UNORM }, @@ -1535,15 +1535,15 @@ static const struct exact_format_mapping rgba8888_tbl[] = static const struct exact_format_mapping rgbx8888_tbl[] = { - { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_X8R8G8B8_UNORM }, - { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_B8G8R8X8_UNORM }, - { GL_BGRA, GL_UNSIGNED_BYTE, PIPE_FORMAT_B8G8R8X8_UNORM }, - { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_X8B8G8R8_UNORM }, - { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_X8B8G8R8_UNORM }, - { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_R8G8B8X8_UNORM }, - { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_R8G8B8X8_UNORM }, + { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_XBGR8888_UNORM }, + { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_XBGR8888_UNORM }, + { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_RGBX8888_UNORM }, + { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_RGBX8888_UNORM }, + { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_XRGB8888_UNORM }, + { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_BGRX8888_UNORM }, { GL_RGBA, GL_UNSIGNED_BYTE, PIPE_FORMAT_R8G8B8X8_UNORM }, { GL_ABGR_EXT, GL_UNSIGNED_BYTE, PIPE_FORMAT_X8B8G8R8_UNORM }, + { GL_BGRA, GL_UNSIGNED_BYTE, PIPE_FORMAT_B8G8R8X8_UNORM }, { 0, 0, 0 } }; diff --git a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c index e5512af2a..d01a21ebf 100644 --- a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c +++ b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c @@ -118,7 +118,7 @@ compute_num_levels(struct gl_context *ctx, baseImage = _mesa_get_tex_image(ctx, texObj, target, texObj->BaseLevel); numLevels = texObj->BaseLevel + baseImage->MaxNumLevels; - numLevels = MIN2(numLevels, texObj->MaxLevel + 1); + numLevels = MIN2(numLevels, (GLuint) texObj->MaxLevel + 1); assert(numLevels >= 1); return numLevels; diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index d6796d7a1..32bc2b37b 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -34,7 +34,6 @@ #include "main/compiler.h" #include "ir.h" #include "ir_visitor.h" -#include "ir_print_visitor.h" #include "ir_expression_flattening.h" #include "glsl_types.h" #include "glsl_parser_extras.h" @@ -1396,9 +1395,9 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir) this->result.file = PROGRAM_UNDEFINED; ir->operands[operand]->accept(this); if (this->result.file == PROGRAM_UNDEFINED) { - ir_print_visitor v; printf("Failed to get tree for expression operand:\n"); - ir->operands[operand]->accept(&v); + ir->operands[operand]->print(); + printf("\n"); exit(1); } op[operand] = this->result; @@ -4995,7 +4994,6 @@ get_mesa_program(struct gl_context *ctx, glsl_to_tgsi_visitor* v; struct gl_program *prog; GLenum target; - const char *target_string; bool progress; struct gl_shader_compiler_options *options = &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(shader->Type)]; @@ -5006,17 +5004,14 @@ get_mesa_program(struct gl_context *ctx, case GL_VERTEX_SHADER: target = GL_VERTEX_PROGRAM_ARB; ptarget = PIPE_SHADER_VERTEX; - target_string = "vertex"; break; case GL_FRAGMENT_SHADER: target = GL_FRAGMENT_PROGRAM_ARB; ptarget = PIPE_SHADER_FRAGMENT; - target_string = "fragment"; break; case GL_GEOMETRY_SHADER: target = GL_GEOMETRY_PROGRAM_NV; ptarget = PIPE_SHADER_GEOMETRY; - target_string = "geometry"; break; default: assert(!"should not be reached"); @@ -5106,7 +5101,8 @@ get_mesa_program(struct gl_context *ctx, if (ctx->Shader.Flags & GLSL_DUMP) { printf("\n"); - printf("GLSL IR for linked %s program %d:\n", target_string, + printf("GLSL IR for linked %s program %d:\n", + _mesa_glsl_shader_target_name(shader->Type), shader_program->Name); _mesa_print_ir(shader->ir, NULL); printf("\n"); diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c index ec876087c..9c2b4d24e 100644 --- a/mesalib/src/mesa/state_tracker/st_manager.c +++ b/mesalib/src/mesa/state_tracker/st_manager.c @@ -431,8 +431,6 @@ st_framebuffer_create(struct st_framebuffer_iface *stfbi) stfb->stamp = 0; st_framebuffer_update_attachments(stfb); - stfb->Base.Initialized = GL_TRUE; - return stfb; } diff --git a/mesalib/src/mesa/vbo/vbo_exec_array.c b/mesalib/src/mesa/vbo/vbo_exec_array.c index 9dadd0421..75831faf9 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_array.c +++ b/mesalib/src/mesa/vbo/vbo_exec_array.c @@ -1371,7 +1371,7 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode, static void GLAPIENTRY vbo_exec_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type, - const GLvoid **indices, + const GLvoid * const *indices, GLsizei primcount) { GET_CURRENT_CONTEXT(ctx); diff --git a/mesalib/src/mesa/vbo/vbo_save_api.c b/mesalib/src/mesa/vbo/vbo_save_api.c index 26951bd94..2028d8b2c 100644 --- a/mesalib/src/mesa/vbo/vbo_save_api.c +++ b/mesalib/src/mesa/vbo/vbo_save_api.c @@ -1182,7 +1182,7 @@ _save_OBE_DrawRangeElements(GLenum mode, GLuint start, GLuint end, static void GLAPIENTRY _save_OBE_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type, - const GLvoid **indices, GLsizei primcount) + const GLvoid * const *indices, GLsizei primcount) { GLsizei i; |