Mesa (master): mesa/shaderapi: add a getter for GL_SPIR_V_BINARY_ARB
Module: Mesa Branch: master Commit: 4ccd00d7626b26f8aac02fe71508951223f9ad45 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4ccd00d7626b26f8aac02fe71508951223f9ad45 Author: Nicolai Hähnle Date: Sat Jun 10 19:46:58 2017 +0200 mesa/shaderapi: add a getter for GL_SPIR_V_BINARY_ARB v2: Use the 'spirv_data' member of gl_shader instead of a dedicated flag. (Timothy Arceri) Reviewed-by: Ian Romanick --- src/mesa/main/shaderapi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index f66172c479..0f65cb0a96 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -966,6 +966,9 @@ get_shaderiv(struct gl_context *ctx, GLuint name, GLenum pname, GLint *params) case GL_SHADER_SOURCE_LENGTH: *params = shader->Source ? strlen((char *) shader->Source) + 1 : 0; break; + case GL_SPIR_V_BINARY_ARB: + *params = (shader->spirv_data != NULL); + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetShaderiv(pname)"); return; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: refuse to compile SPIR-V shaders or link mixed shaders
Module: Mesa Branch: master Commit: accb7d439094ce284b139a5e87930b489702f8eb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=accb7d439094ce284b139a5e87930b489702f8eb Author: Nicolai Hähnle Date: Sat Jun 10 19:57:18 2017 +0200 mesa: refuse to compile SPIR-V shaders or link mixed shaders Note that gl_shader::CompileStatus will also indicate whether a shader has been successfully specialized. v2: Use the 'spirv_data' member of gl_shader to know if it is a SPIR-V shader, instead of a dedicated flag. (Timothy Arceri) v3: Use bool instead of GLboolean. (Ian Romanick) Reviewed-by: Ian Romanick --- src/mesa/main/shaderapi.c | 12 src/mesa/program/ir_to_mesa.cpp | 17 - 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 0f65cb0a96..d824a88ca2 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1097,6 +1097,18 @@ _mesa_compile_shader(struct gl_context *ctx, struct gl_shader *sh) if (!sh) return; + /* The GL_ARB_gl_spirv spec says: +* +*"Add a new error for the CompileShader command: +* +* An INVALID_OPERATION error is generated if the SPIR_V_BINARY_ARB +* state of is TRUE." +*/ + if (sh->spirv_data) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glCompileShader(SPIR-V)"); + return; + } + if (!sh->Source) { /* If the user called glCompileShader without first calling * glShaderSource, we should fail to compile, but not raise a GL_ERROR. diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index ea74539cd7..5f663b3d09 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -3083,6 +3083,7 @@ void _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) { unsigned int i; + bool spirv; _mesa_clear_shader_program_data(ctx, prog); @@ -3092,7 +3093,21 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) for (i = 0; i < prog->NumShaders; i++) { if (!prog->Shaders[i]->CompileStatus) { -linker_error(prog, "linking with uncompiled shader"); +linker_error(prog, "linking with uncompiled/unspecialized shader"); + } + + if (!i) { + spirv = (prog->Shaders[i]->spirv_data != NULL); + } else if (spirv && !prog->Shaders[i]->spirv_data) { + /* The GL_ARB_gl_spirv spec adds a new bullet point to the list of + * reasons LinkProgram can fail: + * + *"All the shader objects attached to do not have the + * same value for the SPIR_V_BINARY_ARB state." + */ + linker_error(prog, + "not all attached shaders have the same " + "SPIR_V_BINARY_ARB state"); } } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa/glspirv: Add struct gl_shader_spirv_data
Module: Mesa Branch: master Commit: a8889f5cc7129c1f8942248d620f64b4496e8f35 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a8889f5cc7129c1f8942248d620f64b4496e8f35 Author: Eduardo Lima Mitev Date: Mon Nov 13 13:57:46 2017 +0100 mesa/glspirv: Add struct gl_shader_spirv_data This is a per-shader structure holding the SPIR-V data associated with the shader (binary module, specialization constants and entry-point). This is needed because both gl_shader and gl_linked_shader need to share this data. Instead of copying the data, we pass a reference to it upon program linking. That's why it is reference-counted. This struct is created and associated with the shader upon calling glShaderBinary(), then subsequently filled up by the call to glSpecializeShaderARB(). v2: Readability improvements (Ian Romanick) Reviewed-by: Ian Romanick --- src/mesa/main/glspirv.c | 17 + src/mesa/main/glspirv.h | 25 + 2 files changed, 42 insertions(+) diff --git a/src/mesa/main/glspirv.c b/src/mesa/main/glspirv.c index d4832db549..8d1e652e08 100644 --- a/src/mesa/main/glspirv.c +++ b/src/mesa/main/glspirv.c @@ -42,6 +42,23 @@ _mesa_spirv_module_reference(struct gl_spirv_module **dest, p_atomic_inc(&src->RefCount); } +void +_mesa_shader_spirv_data_reference(struct gl_shader_spirv_data **dest, + struct gl_shader_spirv_data *src) +{ + struct gl_shader_spirv_data *old = *dest; + + if (old && p_atomic_dec_zero(&old->RefCount)) { + _mesa_spirv_module_reference(&(*dest)->SpirVModule, NULL); + ralloc_free(old); + } + + *dest = src; + + if (src) + p_atomic_inc(&src->RefCount); +} + void GLAPIENTRY _mesa_SpecializeShaderARB(GLuint shader, const GLchar *pEntryPoint, diff --git a/src/mesa/main/glspirv.h b/src/mesa/main/glspirv.h index 4e033735cf..b8a0125ea9 100644 --- a/src/mesa/main/glspirv.h +++ b/src/mesa/main/glspirv.h @@ -42,10 +42,35 @@ struct gl_spirv_module { char Binary[0]; }; +/** + * SPIR-V data needed to compile and link a SPIR-V shader. + * + * It includes a SPIR-V binary that is potentially shared among different + * shaders; and shader-specific specialization constants and entry point. + * + * It is reference-counted because it is shared between gl_shader and its + * corresponding gl_linked_shader. + */ +struct gl_shader_spirv_data { + GLint RefCount; + + struct gl_spirv_module *SpirVModule; + + GLchar *SpirVEntryPoint; + + GLuint NumSpecializationConstants; + GLuint *SpecializationConstantsIndex; + GLuint *SpecializationConstantsValue; +}; + void _mesa_spirv_module_reference(struct gl_spirv_module **dest, struct gl_spirv_module *src); +void +_mesa_shader_spirv_data_reference(struct gl_shader_spirv_data **dest, + struct gl_shader_spirv_data *src); + /** * \name API functions */ ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: add GL_ARB_gl_spirv boilerplate
Module: Mesa Branch: master Commit: 46b21b8f9060faafdb838aa94f2aef35de03901a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=46b21b8f9060faafdb838aa94f2aef35de03901a Author: Nicolai Hähnle Date: Sat Jun 10 19:39:02 2017 +0200 mesa: add GL_ARB_gl_spirv boilerplate v2: * Add meson build bits (Eric Engestrom) * Return INVALID_OPERATION error on SpecializeShaderARB (Ian Romanick) v3: Include boilerplate for the GL 4.6 alias of glSpecializeShaderARB (Neil Roberts) Reviewed-by: Emil Velikov Reviewed-by: Ian Romanick Reviewed-by: Timothy Arceri --- src/mapi/glapi/gen/ARB_gl_spirv.xml | 21 ++ src/mapi/glapi/gen/GL4x.xml | 11 +++ src/mapi/glapi/gen/Makefile.am | 1 + src/mapi/glapi/gen/gl_API.xml | 4 +++ src/mapi/glapi/gen/gl_genexec.py| 1 + src/mapi/glapi/gen/meson.build | 1 + src/mesa/Makefile.sources | 2 ++ src/mesa/main/extensions_table.h| 1 + src/mesa/main/glspirv.c | 39 + src/mesa/main/glspirv.h | 51 + src/mesa/main/mtypes.h | 1 + src/mesa/main/tests/dispatch_sanity.cpp | 3 ++ src/mesa/meson.build| 2 ++ 13 files changed, 138 insertions(+) diff --git a/src/mapi/glapi/gen/ARB_gl_spirv.xml b/src/mapi/glapi/gen/ARB_gl_spirv.xml new file mode 100644 index 00..0dd615480f --- /dev/null +++ b/src/mapi/glapi/gen/ARB_gl_spirv.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mapi/glapi/gen/GL4x.xml b/src/mapi/glapi/gen/GL4x.xml index 88dba5cd71..0a8094166c 100644 --- a/src/mapi/glapi/gen/GL4x.xml +++ b/src/mapi/glapi/gen/GL4x.xml @@ -73,6 +73,17 @@ + + + + + + + + + + + diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am index 87d8517b7b..35e37e95a9 100644 --- a/src/mapi/glapi/gen/Makefile.am +++ b/src/mapi/glapi/gen/Makefile.am @@ -144,6 +144,7 @@ API_XML = \ ARB_framebuffer_object.xml \ ARB_get_program_binary.xml \ ARB_get_texture_sub_image.xml \ + ARB_gl_spirv.xml \ ARB_gpu_shader_fp64.xml \ ARB_gpu_shader_int64.xml \ ARB_gpu_shader5.xml \ diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index eb1d9b83b2..d3594cfe19 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -8400,6 +8400,10 @@ http://www.w3.org/2001/XInclude"/> + + +http://www.w3.org/2001/XInclude"/> + diff --git a/src/mapi/glapi/gen/gl_genexec.py b/src/mapi/glapi/gen/gl_genexec.py index b7b22328ff..aaff9f230b 100644 --- a/src/mapi/glapi/gen/gl_genexec.py +++ b/src/mapi/glapi/gen/gl_genexec.py @@ -77,6 +77,7 @@ header = """/** #include "main/eval.h" #include "main/externalobjects.h" #include "main/get.h" +#include "main/glspirv.h" #include "main/feedback.h" #include "main/fog.h" #include "main/fbobject.h" diff --git a/src/mapi/glapi/gen/meson.build b/src/mapi/glapi/gen/meson.build index 599f094e99..a6a93cc83b 100644 --- a/src/mapi/glapi/gen/meson.build +++ b/src/mapi/glapi/gen/meson.build @@ -52,6 +52,7 @@ api_xml_files = files( 'ARB_framebuffer_object.xml', 'ARB_get_program_binary.xml', 'ARB_get_texture_sub_image.xml', + 'ARB_gl_spirv.xml', 'ARB_gpu_shader_fp64.xml', 'ARB_gpu_shader_int64.xml', 'ARB_gpu_shader5.xml', diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources index d8b1eb1f99..53fa486364 100644 --- a/src/mesa/Makefile.sources +++ b/src/mesa/Makefile.sources @@ -118,6 +118,8 @@ MAIN_FILES = \ main/getstring.c \ main/glformats.c \ main/glformats.h \ + main/glspirv.c \ + main/glspirv.h \ main/glthread.c \ main/glthread.h \ main/glheader.h \ diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index 5b66e7d30d..ab15ceb941 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -72,6 +72,7 @@ EXT(ARB_framebuffer_object , ARB_framebuffer_object EXT(ARB_framebuffer_sRGB, EXT_framebuffer_sRGB , GLL, GLC, x , x , 1998) EXT(ARB_get_program_binary , dummy_true , GLL, GLC, x , x , 2010) EXT(ARB_get_texture_sub_image , dummy_true , GLL, GLC, x , x , 2014) +EXT(ARB_gl_spirv, ARB_gl_spirv , x, GLC, x , x , 2016) EXT(ARB_gpu_shader5 , ARB_gpu_shader5 , x , GLC, x , x , 2010) EXT(ARB_gpu_shader_fp64 , ARB_gpu_shader_fp64 , x , GLC, x , x , 2010) EXT(ARB_gpu_shader_int64, ARB_gpu_shader_int64 , x , GLC, x , x , 201
Mesa (master): mesa/glspirv: Add struct gl_spirv_module
Module: Mesa Branch: master Commit: 74f98ab76f2a21ef511e6bbddaa08ac1748aca2e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=74f98ab76f2a21ef511e6bbddaa08ac1748aca2e Author: Nicolai Hähnle Date: Sat Jun 10 20:14:44 2017 +0200 mesa/glspirv: Add struct gl_spirv_module v2: * Make the SPIR-V module struct part of a larger gl_shader_spirv_data struct that will be introduced later, and don't reference it directly in gl_shader. (Eduardo Lima) * Readability improvements (Ian Romanick) Reviewed-by: Ian Romanick --- src/mesa/main/glspirv.c | 17 + src/mesa/main/glspirv.h | 16 2 files changed, 33 insertions(+) diff --git a/src/mesa/main/glspirv.c b/src/mesa/main/glspirv.c index 3989f42424..d4832db549 100644 --- a/src/mesa/main/glspirv.c +++ b/src/mesa/main/glspirv.c @@ -25,6 +25,23 @@ #include "errors.h" +#include "util/u_atomic.h" + +void +_mesa_spirv_module_reference(struct gl_spirv_module **dest, + struct gl_spirv_module *src) +{ + struct gl_spirv_module *old = *dest; + + if (old && p_atomic_dec_zero(&old->RefCount)) + free(old); + + *dest = src; + + if (src) + p_atomic_inc(&src->RefCount); +} + void GLAPIENTRY _mesa_SpecializeShaderARB(GLuint shader, const GLchar *pEntryPoint, diff --git a/src/mesa/main/glspirv.h b/src/mesa/main/glspirv.h index 1de88717fa..4e033735cf 100644 --- a/src/mesa/main/glspirv.h +++ b/src/mesa/main/glspirv.h @@ -31,6 +31,22 @@ extern "C" { #endif /** + * A SPIR-V module contains the raw SPIR-V binary as set by ShaderBinary. + * + * It is reference-counted, because the same module can be attached to multiple + * shader objects simultaneously. + */ +struct gl_spirv_module { + unsigned RefCount; + GLint Length; + char Binary[0]; +}; + +void +_mesa_spirv_module_reference(struct gl_spirv_module **dest, + struct gl_spirv_module *src); + +/** * \name API functions */ /*@{*/ ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: implement SPIR-V loading in glShaderBinary
Module: Mesa Branch: master Commit: 5bc03d250861df6836f9c9fe37e0609c1777a87b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5bc03d250861df6836f9c9fe37e0609c1777a87b Author: Nicolai Hähnle Date: Sat Jun 10 20:35:21 2017 +0200 mesa: implement SPIR-V loading in glShaderBinary v2: * Add a gl_shader_spirv_data member to gl_shader, which already encapsulates a gl_spirv_module where the binary will be saved. (Eduardo Lima) * Just use the 'spirv_data' member to know whether a gl_shader has the SPIR_V_BINARY_ARB state. (Timothy Arceri) * Remove redundant argument checks. Move extension presence check to API entry point where the rest of checks are. Retype 'n' and 'length'arguments to use the correct and more standard types. (Ian Romanick) * Fix some nitpicks. (Ian Romanick) Reviewed-by: Ian Romanick --- src/mesa/main/glspirv.c | 43 +++ src/mesa/main/glspirv.h | 5 + src/mesa/main/mtypes.h| 4 src/mesa/main/shaderapi.c | 46 +++--- src/mesa/main/shaderobj.c | 2 ++ 5 files changed, 97 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/glspirv.c b/src/mesa/main/glspirv.c index 8d1e652e08..7eb8f906c2 100644 --- a/src/mesa/main/glspirv.c +++ b/src/mesa/main/glspirv.c @@ -25,6 +25,8 @@ #include "errors.h" +#include "errors.h" + #include "util/u_atomic.h" void @@ -59,6 +61,47 @@ _mesa_shader_spirv_data_reference(struct gl_shader_spirv_data **dest, p_atomic_inc(&src->RefCount); } +void +_mesa_spirv_shader_binary(struct gl_context *ctx, + unsigned n, struct gl_shader **shaders, + const void* binary, size_t length) +{ + struct gl_spirv_module *module; + struct gl_shader_spirv_data *spirv_data; + + assert(length >= 0); + + module = malloc(sizeof(*module) + length); + if (!module) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glShaderBinary"); + return; + } + + p_atomic_set(&module->RefCount, 0); + module->Length = length; + memcpy(&module->Binary[0], binary, length); + + for (int i = 0; i < n; ++i) { + struct gl_shader *sh = shaders[i]; + + spirv_data = rzalloc(NULL, struct gl_shader_spirv_data); + _mesa_shader_spirv_data_reference(&sh->spirv_data, spirv_data); + _mesa_spirv_module_reference(&spirv_data->SpirVModule, module); + + sh->CompileStatus = compile_failure; + + free((void *)sh->Source); + sh->Source = NULL; + free((void *)sh->FallbackSource); + sh->FallbackSource = NULL; + + ralloc_free(sh->ir); + sh->ir = NULL; + ralloc_free(sh->symbols); + sh->symbols = NULL; + } +} + void GLAPIENTRY _mesa_SpecializeShaderARB(GLuint shader, const GLchar *pEntryPoint, diff --git a/src/mesa/main/glspirv.h b/src/mesa/main/glspirv.h index b8a0125ea9..ba281f68be 100644 --- a/src/mesa/main/glspirv.h +++ b/src/mesa/main/glspirv.h @@ -71,6 +71,11 @@ void _mesa_shader_spirv_data_reference(struct gl_shader_spirv_data **dest, struct gl_shader_spirv_data *src); +void +_mesa_spirv_shader_binary(struct gl_context *ctx, + unsigned n, struct gl_shader **shaders, + const void* binary, size_t length); + /** * \name API functions */ diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index ceb7ecc960..b372921e9f 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -98,6 +98,7 @@ struct st_context; struct gl_uniform_storage; struct prog_instruction; struct gl_program_parameter_list; +struct gl_shader_spirv_data; struct set; struct vbo_context; /*@}*/ @@ -2645,6 +2646,9 @@ struct gl_shader GLuint TransformFeedbackBufferStride[MAX_FEEDBACK_BUFFERS]; struct gl_shader_info info; + + /* ARB_gl_spirv related data */ + struct gl_shader_spirv_data *spirv_data; }; diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 4607cbb99b..f66172c479 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -42,6 +42,7 @@ #include "main/context.h" #include "main/dispatch.h" #include "main/enums.h" +#include "main/glspirv.h" #include "main/hash.h" #include "main/mtypes.h" #include "main/pipelineobj.h" @@ -1056,6 +1057,16 @@ set_shader_source(struct gl_shader *sh, const GLchar *source) { assert(sh); + /* The GL_ARB_gl_spirv spec adds the following to the end of the description +* of ShaderSource: +* +* "If was previously associated with a SPIR-V module (via the +*ShaderBinary command), that association is broken. Upon successful +*completion of this command the SPIR_V_BINARY_ARB state of +*is set to FALSE." +*/ + _mesa_shader_spirv_data_reference(&sh->spirv_data, NULL); + if (sh->CompileStatus == compile_skipped && !sh->FallbackSource) { /* If shader was previously compiled back-u
Mesa (master): i915g: Remove a few unused variables
Module: Mesa Branch: master Commit: 1d8111ebacd05f7e5974c5eb04354ee97796f9d4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1d8111ebacd05f7e5974c5eb04354ee97796f9d4 Author: Eduardo Lima Mitev Date: Fri Aug 25 08:55:04 2017 +0200 i915g: Remove a few unused variables Reviewed-by: Kenneth Graunke --- src/gallium/drivers/i915/i915_fpc_translate.c | 16 1 file changed, 16 deletions(-) diff --git a/src/gallium/drivers/i915/i915_fpc_translate.c b/src/gallium/drivers/i915/i915_fpc_translate.c index a9601e82ca..2eaa1e64ef 100644 --- a/src/gallium/drivers/i915/i915_fpc_translate.c +++ b/src/gallium/drivers/i915/i915_fpc_translate.c @@ -77,21 +77,6 @@ static unsigned passthrough_program[] = 0 }; - -/* 1, -1/3!, 1/5!, -1/7! */ -static const float scs_sin_constants[4] = { 1.0, - -1.0f / (3 * 2 * 1), - 1.0f / (5 * 4 * 3 * 2 * 1), - -1.0f / (7 * 6 * 5 * 4 * 3 * 2 * 1) -}; - -/* 1, -1/2!, 1/4!, -1/6! */ -static const float scs_cos_constants[4] = { 1.0, - -1.0f / (2 * 1), - 1.0f / (4 * 3 * 2 * 1), - -1.0f / (6 * 5 * 4 * 3 * 2 * 1) -}; - /* 2*pi, -(2*pi)^3/3!, (2*pi)^5/5!, -(2*pi)^7/7! */ static const float sin_constants[4] = { 2.0 * M_PI, -8.0f * M_PI * M_PI * M_PI / (3 * 2 * 1), @@ -495,7 +480,6 @@ i915_translate_instruction(struct i915_fp_compile *p, const struct i915_full_instruction *inst, struct i915_fragment_shader *fs) { - uint writemask; uint src0, src1, src2, flags; uint tmp = 0; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): getteximage: Return correct error value when texure object is not found
Module: Mesa Branch: master Commit: 633c959faeae5099fd095f27da7b954e4a36254b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=633c959faeae5099fd095f27da7b954e4a36254b Author: Eduardo Lima Mitev Date: Wed Feb 15 12:14:40 2017 +0100 getteximage: Return correct error value when texure object is not found glGetTextureSubImage() and glGetCompressedTextureSubImage() are currently returning INVALID_OPERATION error when the passed texture argument does not correspond to an existing texture object. However, the error should be INVALID_VALUE instead. From OpenGL 4.5 spec PDF, section '8.11. Texture Queries', page 236: "An INVALID_VALUE error is generated if texture is not the name of an existing texture object." Same wording applies to the compressed version. The INVALID_OPERATION error is coming from the call to _mesa_lookup_texture_err(). This patch uses _mesa_lookup_texture() instead and emits the correct error in the caller. Fixes: GL45-CTS.get_texture_sub_image.errors_test Reviewed-by: Nicolai Hähnle --- src/mesa/main/texgetimage.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index b0ced1e..c0c50b0 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -1459,9 +1459,10 @@ _mesa_GetTextureSubImage(GLuint texture, GLint level, GET_CURRENT_CONTEXT(ctx); static const char *caller = "glGetTextureSubImage"; struct gl_texture_object *texObj = - _mesa_lookup_texture_err(ctx, texture, caller); + _mesa_lookup_texture(ctx, texture); if (!texObj) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(texture)", caller); return; } @@ -1775,8 +1776,9 @@ _mesa_GetCompressedTextureSubImage(GLuint texture, GLint level, static const char *caller = "glGetCompressedTextureImage"; struct gl_texture_object *texObj; - texObj = _mesa_lookup_texture_err(ctx, texture, caller); + texObj = _mesa_lookup_texture(ctx, texture); if (!texObj) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(texture)", caller); return; } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): texgetimage: Add check for the effective target to GetTextureSubImage
Module: Mesa Branch: master Commit: e198a64e3532af9b30d7c3fac4d092ecea7d2e41 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e198a64e3532af9b30d7c3fac4d092ecea7d2e41 Author: Eduardo Lima Mitev Date: Thu Feb 2 17:07:24 2017 +0100 texgetimage: Add check for the effective target to GetTextureSubImage OpenGL 4.5 spec, section "8.11.4 Texture Image Queries", page 233 of the PDF states: "An INVALID_OPERATION error is generated if texture is the name of a buffer or multisample texture." This is currently not being checked and e.g a multisample texture image can be passed down to the driver hook. On i965, it is crashing the driver with an assertion: intel_mipmap_tree.c:3125: intel_miptree_map: Assertion `mt->num_samples <= 1' failed. v2: (Ilia Mirkin) Move the check from gettextimage_error_check() to GetTextureSubImage() and use the texObj target. Reviewed-by: Ilia Mirkin --- src/mesa/main/texgetimage.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index d5cb163..b0ced1e 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -1465,6 +1465,12 @@ _mesa_GetTextureSubImage(GLuint texture, GLint level, return; } + if (!legal_getteximage_target(ctx, texObj->Target, true)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(buffer/multisample texture)", caller); + return; + } + if (getteximage_error_check(ctx, texObj, texObj->Target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, bufSize, pixels, caller)) { ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965/blorp: fix release build unused variable warning
Module: Mesa Branch: master Commit: 6092169b96edb1eb85fd195c426858d4430f9bb3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6092169b96edb1eb85fd195c426858d4430f9bb3 Author: Grazvydas Ignotas Date: Sun Dec 11 21:57:44 2016 +0200 i965/blorp: fix release build unused variable warning Signed-off-by: Grazvydas Ignotas Reviewed-by: Eduardo Lima Mitev --- src/mesa/drivers/dri/i965/brw_blorp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_blorp.c b/src/mesa/drivers/dri/i965/brw_blorp.c index 4c1d858..43ac3be 100644 --- a/src/mesa/drivers/dri/i965/brw_blorp.c +++ b/src/mesa/drivers/dri/i965/brw_blorp.c @@ -813,8 +813,6 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb, can_fast_clear = false; const unsigned logical_layer = irb_logical_mt_layer(irb); - const bool is_lossless_compressed = intel_miptree_is_lossless_compressed( - brw, irb->mt); const enum intel_fast_clear_state fast_clear_state = intel_miptree_get_fast_clear_state(irb->mt, irb->mt_level, logical_layer); @@ -850,7 +848,7 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb, * it now. */ if (!irb->mt->mcs_buf) { - assert(!is_lossless_compressed); + assert(!intel_miptree_is_lossless_compressed(brw, irb->mt)); if (!intel_miptree_alloc_non_msrt_mcs(brw, irb->mt, false)) { /* MCS allocation failed--probably this will only happen in * out-of-memory conditions. But in any case, try to recover ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): anv: fix release build unused variable warnings
Module: Mesa Branch: master Commit: 3a1b15c3921d25ea2e6e81f500c3f45c84b95817 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3a1b15c3921d25ea2e6e81f500c3f45c84b95817 Author: Grazvydas Ignotas Date: Sat Dec 10 21:10:48 2016 +0200 anv: fix release build unused variable warnings Signed-off-by: Grazvydas Ignotas Reviewed-by: Eduardo Lima Mitev --- src/intel/vulkan/anv_blorp.c | 3 ++- src/intel/vulkan/genX_cmd_buffer.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c index 159e4a0..b431d6a 100644 --- a/src/intel/vulkan/anv_blorp.c +++ b/src/intel/vulkan/anv_blorp.c @@ -909,7 +909,8 @@ anv_cmd_buffer_alloc_blorp_binding_table(struct anv_cmd_buffer *cmd_buffer, state_offset); if (bt_state.map == NULL) { /* We ran out of space. Grab a new binding table block. */ - VkResult result = anv_cmd_buffer_new_binding_table_block(cmd_buffer); + MAYBE_UNUSED VkResult result = + anv_cmd_buffer_new_binding_table_block(cmd_buffer); assert(result == VK_SUCCESS); /* Re-emit state base addresses so we get the new surface state base diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index f761d9a..6131cfb 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -697,7 +697,7 @@ genX(cmd_buffer_config_l3)(struct anv_cmd_buffer *cmd_buffer, assert(!urb_low_bw || cfg->n[GEN_L3P_URB] == cfg->n[GEN_L3P_SLM]); /* Minimum number of ways that can be allocated to the URB. */ - const unsigned n0_urb = (devinfo->is_baytrail ? 32 : 0); + MAYBE_UNUSED const unsigned n0_urb = devinfo->is_baytrail ? 32 : 0; assert(cfg->n[GEN_L3P_URB] >= n0_urb); uint32_t l3sqcr1, l3cr2, l3cr3; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): intel/aubinator: fix 32bit shift overflow warning
Module: Mesa Branch: master Commit: b58d1eecc6516749c160942855a9d6b558f1e947 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b58d1eecc6516749c160942855a9d6b558f1e947 Author: Grazvydas Ignotas Date: Sat Dec 10 21:10:46 2016 +0200 intel/aubinator: fix 32bit shift overflow warning Doesn't look like this can work on 32bit, just rids of annoying warning. Signed-off-by: Grazvydas Ignotas Reviewed-by: Eduardo Lima Mitev --- src/intel/tools/aubinator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c index 5e3a684..e2bec8f 100644 --- a/src/intel/tools/aubinator.c +++ b/src/intel/tools/aubinator.c @@ -1297,7 +1297,7 @@ int main(int argc, char *argv[]) file = aub_file_open(input_file); /* mmap a terabyte for our gtt space. */ - gtt_size = 1ul << 40; + gtt_size = 1ull << 40; gtt = mmap(NULL, gtt_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); if (gtt == MAP_FAILED) { ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): main/texobj: Check that texture id > 0 before looking it up in hash-table
Module: Mesa Branch: master Commit: 89cbe0d21f8ed47f992b04b4a5595c4801d2b397 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=89cbe0d21f8ed47f992b04b4a5595c4801d2b397 Author: Eduardo Lima Mitev Date: Wed Nov 23 14:44:05 2016 +0100 main/texobj: Check that texture id > 0 before looking it up in hash-table _mesa_lookup_texture_err() is not currently checking that the texture-id can be zero, but _mesa_HashLookup() doesn't expect the key to be zero, and will fail an assertion. Considering that _mesa_lookup_texture_err() is called from _mesa_GetTextureImage and _mesa_GetTextureSubImage with user provided arguments, we must validate the texture-id before looking it up in the hash-table. Reviewed-by: Nicolai Hähnle --- src/mesa/main/texobj.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index fbd498d..e5b7070 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -116,9 +116,10 @@ _mesa_lookup_texture(struct gl_context *ctx, GLuint id) struct gl_texture_object * _mesa_lookup_texture_err(struct gl_context *ctx, GLuint id, const char* func) { - struct gl_texture_object *texObj; + struct gl_texture_object *texObj = NULL; - texObj = _mesa_lookup_texture(ctx, id); /* Returns NULL if not found. */ + if (id > 0) + texObj = _mesa_lookup_texture(ctx, id); /* Returns NULL if not found. */ if (!texObj) _mesa_error(ctx, GL_INVALID_OPERATION, "%s(texture)", func); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa/getteximage: Add validation of target to glGetTextureImage
Module: Mesa Branch: master Commit: 116fed80ff1e65802ecf0244a10a68b83e979258 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=116fed80ff1e65802ecf0244a10a68b83e979258 Author: Eduardo Lima Mitev Date: Wed Nov 23 14:09:59 2016 +0100 mesa/getteximage: Add validation of target to glGetTextureImage There is an specific list of texture targets that can be used with glGetTextureImage. From OpenGL 4.5 spec, section '8.11 Texture Queries', page 234 of the PDF: "An INVALID_ENUM error is generated if the effective target is not one of TEXTURE_1D , TEXTURE_2D , TEXTURE_3D , TEXTURE_1D_- ARRAY , TEXTURE_2D_ARRAY , TEXTURE_CUBE_MAP_ARRAY , TEXTURE_- RECTANGLE , one of the targets from table 8.19 (for GetTexImage and GetnTexImage only), or TEXTURE_CUBE_MAP (for GetTextureImage only)." We are currently not validating the target for glGetTextureImage. As an example, calling this function on a texture with target GL_TEXTURE_2D_MULTISAMPLE should return INVALID_ENUM, but instead it hits an assertion down the road in the i965 driver. Reviewed-by: Nicolai Hähnle --- src/mesa/main/texgetimage.c | 5 + 1 file changed, 5 insertions(+) diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index 0186819..d5cb163 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -1429,6 +1429,11 @@ _mesa_GetTextureImage(GLuint texture, GLint level, GLenum format, GLenum type, return; } + if (!legal_getteximage_target(ctx, texObj->Target, true)) { + _mesa_error(ctx, GL_INVALID_ENUM, "%s", caller); + return; + } + get_texture_image_dims(texObj, texObj->Target, level, &width, &height, &depth); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): main/getteximage: Use the height argument to calculate memcpy copy size
Module: Mesa Branch: master Commit: 6e8f12619f921673b48f18f9856d9e919869e1ed URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6e8f12619f921673b48f18f9856d9e919869e1ed Author: Eduardo Lima Mitev Date: Tue Nov 22 12:12:48 2016 +0100 main/getteximage: Use the height argument to calculate memcpy copy size In get_tex_memcpy, when copying texture data directly from source to destination (when row strides match for both src and dst), the copy size is currently calculated using the full texture height instead of the sub-region height parameter that was passed. This can cause a read past the end of the mapped buffer when y-offset is greater than zero, leading to a segfault. Fixes CTS test (from crash to pass): * GL45-CTS/get_texture_sub_image/functional_test v2: (Jason) Use the passed 'height' instead of copying til the end of the buffer (tex-height - yoffset). Reviewed-by: Jason Ekstrand --- src/mesa/main/texgetimage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index b900278..0186819 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -654,7 +654,7 @@ get_tex_memcpy(struct gl_context *ctx, if (src) { if (bytesPerRow == dstRowStride && bytesPerRow == srcRowStride) { -memcpy(dst, src, bytesPerRow * texImage->Height); +memcpy(dst, src, bytesPerRow * height); } else { GLuint row; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): meta/GetTexSubImage: Account for GL_PACK_SKIP_IMAGES on compressed textures
Module: Mesa Branch: master Commit: e73513f3c85f45a05a23dbdcda7901812fc4d4fa URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e73513f3c85f45a05a23dbdcda7901812fc4d4fa Author: Eduardo Lima Mitev Date: Mon Nov 14 15:25:14 2016 -0800 meta/GetTexSubImage: Account for GL_PACK_SKIP_IMAGES on compressed textures This option was being ignored when packing compressed 3D and cube textures. Fixes CTS test (on gen8+): * GL45-CTS.gtf32.GL3Tests.packed_pixels.packed_pixels_pixelstore v2: Drop API checks. v3 (Ken): Just apply the existing code in more cases. Reviewed-by: Kenneth Graunke --- src/mesa/drivers/common/meta.c | 20 +--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 5ab1e6c..99c85cf 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -3243,8 +3243,20 @@ _mesa_meta_GetTexSubImage(struct gl_context *ctx, for (slice = 0; slice < depth; slice++) { void *dst; - if (texImage->TexObject->Target == GL_TEXTURE_2D_ARRAY - || texImage->TexObject->Target == GL_TEXTURE_CUBE_MAP_ARRAY) { + /* Section 8.11.4 (Texture Image Queries) of the GL 4.5 spec says: + * + *"For three-dimensional, two-dimensional array, cube map array, + * and cube map textures pixel storage operations are applied as + * if the image were two-dimensional, except that the additional + * pixel storage state values PACK_IMAGE_HEIGHT and + * PACK_SKIP_IMAGES are applied. The correspondence of texels to + * memory locations is as defined for TexImage3D in section 8.5." + */ + switch (texImage->TexObject->Target) { + case GL_TEXTURE_3D: + case GL_TEXTURE_2D_ARRAY: + case GL_TEXTURE_CUBE_MAP: + case GL_TEXTURE_CUBE_MAP_ARRAY: { /* Setup pixel packing. SkipPixels and SkipRows will be applied * in the decompress_texture_image() function's call to * glReadPixels but we need to compute the dest slice's address @@ -3255,9 +3267,11 @@ _mesa_meta_GetTexSubImage(struct gl_context *ctx, packing.SkipRows = 0; dst = _mesa_image_address3d(&packing, pixels, width, height, format, type, slice, 0, 0); +break; } - else { + default: dst = pixels; +break; } result = decompress_texture_image(ctx, texImage, slice, xoffset, yoffset, width, height, ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): vulkan/wsi/x11: Fix behavior of vkGetPhysicalDeviceSurfacePresentModesKHR
Module: Mesa Branch: master Commit: b677b99db5c48ffd1eeef538b962080ac5fd65d9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b677b99db5c48ffd1eeef538b962080ac5fd65d9 Author: Eduardo Lima Mitev Date: Fri Oct 28 14:34:39 2016 +0200 vulkan/wsi/x11: Fix behavior of vkGetPhysicalDeviceSurfacePresentModesKHR x11_surface_get_present_modes() is currently asserting that the number of elements in pPresentModeCount must be greater than or equal to the number of present modes available. This is buggy because pPresentModeCount elements are later copied from the internal modes' array, so if pPresentModeCount is greater, it will overflow it. On top of that, this assertion violates the spec. From the Vulkan 1.0 (revision 32, with KHR extensions), page 581 of the PDF: "If the value of pPresentModeCount is less than the number of presentation modes supported, at most pPresentModeCount values will be written. If pPresentModeCount is smaller than the number of presentation modes supported for the given surface, VK_INCOMPLETE will be returned instead of VK_SUCCESS to indicate that not all the available values were returned." So, the correct behavior is: if pPresentModeCount is greater than the internal number of formats, it is clamped to that many present modes. But if it is lesser than that, then pPresentModeCount elements are copied, and the call returns VK_INCOMPLETE. This fix is similar (but simpler and more readable) than the one I provided in 750d8cad72a for vkGetPhysicalDeviceSurfaceFormatsKHR, which was suffering from the same problem. Reviewed-by: Eric Engestrom --- src/vulkan/wsi/wsi_common_x11.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index efd3fb5..4a232f5 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -418,11 +418,11 @@ x11_surface_get_present_modes(VkIcdSurfaceBase *surface, return VK_SUCCESS; } - assert(*pPresentModeCount >= ARRAY_SIZE(present_modes)); + *pPresentModeCount = MIN2(*pPresentModeCount, ARRAY_SIZE(present_modes)); typed_memcpy(pPresentModes, present_modes, *pPresentModeCount); - *pPresentModeCount = ARRAY_SIZE(present_modes); - return VK_SUCCESS; + return *pPresentModeCount < ARRAY_SIZE(present_modes) ? + VK_INCOMPLETE : VK_SUCCESS; } VkResult wsi_create_xcb_surface(const VkAllocationCallbacks *pAllocator, ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): vulkan/wsi/x11: Smplify implementation of vkGetPhysicalDeviceSurfaceFormatsKHR
Module: Mesa Branch: master Commit: 129da274261b6e79f459e24428591f137bf92ed1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=129da274261b6e79f459e24428591f137bf92ed1 Author: Eduardo Lima Mitev Date: Fri Oct 28 14:45:36 2016 +0200 vulkan/wsi/x11: Smplify implementation of vkGetPhysicalDeviceSurfaceFormatsKHR This patch simplifies x11_surface_get_formats(). It is actually just a readability improvement over the patch I provided earlier this week (750d8cad72). Reviewed-by: Eric Engestrom --- src/vulkan/wsi/wsi_common_x11.c | 11 +++ 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index 4a232f5..8142847 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -396,16 +396,11 @@ x11_surface_get_formats(VkIcdSurfaceBase *surface, return VK_SUCCESS; } - VkResult result = VK_SUCCESS; - - if (*pSurfaceFormatCount > ARRAY_SIZE(formats)) - *pSurfaceFormatCount = ARRAY_SIZE(formats); - else if (*pSurfaceFormatCount < ARRAY_SIZE(formats)) - result = VK_INCOMPLETE; - + *pSurfaceFormatCount = MIN2(*pSurfaceFormatCount, ARRAY_SIZE(formats)); typed_memcpy(pSurfaceFormats, formats, *pSurfaceFormatCount); - return result; + return *pSurfaceFormatCount < ARRAY_SIZE(formats) ? + VK_INCOMPLETE : VK_SUCCESS; } static VkResult ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): vulkan/wsi/x11: Fix behavior of vkGetPhysicalDeviceSurfaceFormatsKHR
Module: Mesa Branch: master Commit: 750d8cad72a532d977df10ffbbdd1902bd06f50b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=750d8cad72a532d977df10ffbbdd1902bd06f50b Author: Eduardo Lima Mitev Date: Tue Oct 25 10:20:12 2016 +0200 vulkan/wsi/x11: Fix behavior of vkGetPhysicalDeviceSurfaceFormatsKHR x11_surface_get_formats() is currently asserting that the number of elements in pSurfaceFormats must be greater than or equal to the number of formats available. This is buggy because pSurfaceFormatsCount elements are later copied from the internal formats' array, so if pSurfaceFormatCount is greater, it will overflow it. On top of that, this assertion violates the spec. From the Vulkan 1.0 (revision 32, with KHR extensions), page 579 of the PDF: "If pSurfaceFormats is NULL, then the number of format pairs supported for the given surface is returned in pSurfaceFormatCount. Otherwise, pSurfaceFormatCount must point to a variable set by the user to the number of elements in the pSurfaceFormats array, and on return the variable is overwritten with the number of structures actually written to pSurfaceFormats. If the value of pSurfaceFormatCount is less than the number of format pairs supported, at most pSurfaceFormatCount structures will be written. If pSurfaceFormatCount is smaller than the number of format pairs supported for the given surface, VK_INCOMPLETE will be returned instead of VK_SUCCESS to indicate that not all the available values were returned." So, the correct behavior is: if pSurfaceFormatCount is greater than the internal number of formats, it is clamped to that many formats. But if it is lesser than that, then pSurfaceFormatCount elements are copied, and the call returns VK_INCOMPLETE. Reviewed-by: Dave Airlie --- src/vulkan/wsi/wsi_common_x11.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index b5832c6..548352e 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -394,11 +394,16 @@ x11_surface_get_formats(VkIcdSurfaceBase *surface, return VK_SUCCESS; } - assert(*pSurfaceFormatCount >= ARRAY_SIZE(formats)); + VkResult result = VK_SUCCESS; + + if (*pSurfaceFormatCount > ARRAY_SIZE(formats)) + *pSurfaceFormatCount = ARRAY_SIZE(formats); + else if (*pSurfaceFormatCount < ARRAY_SIZE(formats)) + result = VK_INCOMPLETE; + typed_memcpy(pSurfaceFormats, formats, *pSurfaceFormatCount); - *pSurfaceFormatCount = ARRAY_SIZE(formats); - return VK_SUCCESS; + return result; } static VkResult ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): glsl/builtin_variables: Populate MaxCombinedShaderStorageBlocks on GLSL 4.40
Module: Mesa Branch: master Commit: a93bb2e33f189c838a80125bcd5ce388f681dcaf URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a93bb2e33f189c838a80125bcd5ce388f681dcaf Author: Eduardo Lima Mitev Date: Fri Jun 10 19:15:33 2016 +0200 glsl/builtin_variables: Populate MaxCombinedShaderStorageBlocks on GLSL 4.40 Built-in variable "MaxCombinedShaderStorageBlocks" was added to GLSL 4.40 revision 9. Section "1.2.1 Changes since revision 8 of GLSL version 4.40", page 3 of the PDF states: "Bug 11734: Add gl_MaxCombinedShaderOutputResources and mark gl_MaxCombinedImageUnitsAndFragmentOutputs as deprecated." Fixes: GL44-CTS.shader_image_load_store.basic-glsl-const Reviewed-by: Kenneth Graunke --- src/compiler/glsl/builtin_variables.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp index 05b3b0b..e5e7380 100644 --- a/src/compiler/glsl/builtin_variables.cpp +++ b/src/compiler/glsl/builtin_variables.cpp @@ -864,7 +864,7 @@ builtin_variable_generator::generate_constants() } } - if (state->is_version(450, 310) || + if (state->is_version(440, 310) || state->ARB_ES3_1_compatibility_enable) { add_const("gl_MaxCombinedShaderOutputResources", state->Const.MaxCombinedShaderOutputResources); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): anv/nir_apply_pipeline_layout: Pass the nir_src from the nir_tex_src
Module: Mesa Branch: master Commit: 7dce4793b7fae65a2ecb63681c5096fb2af2eec4 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7dce4793b7fae65a2ecb63681c5096fb2af2eec4 Author: Eduardo Lima Mitev Date: Sat May 21 09:24:03 2016 +0200 anv/nir_apply_pipeline_layout: Pass the nir_src from the nir_tex_src nir_instr_rewrite_src() expects a nir_src and it is currently being fed a nir_tex_src. This will crash something. Reviewed-by: Jason Ekstrand --- src/intel/vulkan/anv_nir_apply_pipeline_layout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c index ddb099e..6481269 100644 --- a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c +++ b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c @@ -163,7 +163,7 @@ lower_tex_deref(nir_tex_instr *tex, nir_deref_var *deref, * first-class texture source. */ tex->src[tex->num_srcs].src_type = src_type; - nir_instr_rewrite_src(&tex->instr, &tex->src[tex->num_srcs], + nir_instr_rewrite_src(&tex->instr, &tex->src[tex->num_srcs].src, nir_src_for_ssa(index)); tex->num_srcs++; } else { ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965/fs: Silence warnings related to use of uninitialized values
Module: Mesa Branch: master Commit: 767168771376a3ee95d5b1f5b2f5fd577b76391e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=767168771376a3ee95d5b1f5b2f5fd577b76391e Author: Eduardo Lima Mitev Date: Tue May 17 12:21:02 2016 +0200 i965/fs: Silence warnings related to use of uninitialized values brw_fs.cpp: In function ‘const unsigned int* brw_compile_fs(const [...] brw_fs.cpp:6093:64: warning: ‘simd16_grf_start’ may be used uninitialized [...] prog_data->base.dispatch_grf_start_reg = simd16_grf_start; brw_fs.cpp:5996:29: note: ‘simd16_grf_start’ was declared here uint8_t simd8_grf_start, simd16_grf_start; brw_fs.cpp:6094:52: warning: ‘simd16_grf_used’ may be used uninitialized [...] prog_data->reg_blocks_0 = brw_register_blocks(simd16_grf_used); brw_fs.cpp:5997:29: note: ‘simd16_grf_used’ was declared here unsigned simd8_grf_used, simd16_grf_used; (and more) Reviewed-by: Anuj Phogat --- src/mesa/drivers/dri/i965/brw_fs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 65b64b6..a417271 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -6028,8 +6028,8 @@ brw_compile_fs(const struct brw_compiler *compiler, void *log_data, shader); cfg_t *simd8_cfg = NULL, *simd16_cfg = NULL; - uint8_t simd8_grf_start, simd16_grf_start; - unsigned simd8_grf_used, simd16_grf_used; + uint8_t simd8_grf_start = 0, simd16_grf_start = 0; + unsigned simd8_grf_used = 0, simd16_grf_used = 0; fs_visitor v8(compiler, log_data, mem_ctx, key, &prog_data->base, prog, shader, 8, ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): nir/print: Print memory qualifiers in a variable declaration
Module: Mesa Branch: master Commit: 60a5d024164e26b003c491e54392b43f1a3b40cd URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=60a5d024164e26b003c491e54392b43f1a3b40cd Author: Eduardo Lima Mitev Date: Thu May 5 13:52:38 2016 +0200 nir/print: Print memory qualifiers in a variable declaration Reviewed-by: Ian Romanick --- src/compiler/nir/nir_print.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index 9a77faf..a36561e 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -354,6 +354,13 @@ print_var_decl(nir_variable *var, print_state *state) cent, samp, patch, inv, get_variable_mode_str(var->data.mode), glsl_interp_qualifier_name(var->data.interpolation)); + const char *const coher = (var->data.image.coherent) ? "coherent " : ""; + const char *const volat = (var->data.image._volatile) ? "volatile " : ""; + const char *const restr = (var->data.image.restrict_flag) ? "restrict " : ""; + const char *const ronly = (var->data.image.read_only) ? "readonly " : ""; + const char *const wonly = (var->data.image.write_only) ? "writeonly " : ""; + fprintf(fp, "%s%s%s%s%s", coher, volat, restr, ronly, wonly); + glsl_print_type(var->type, fp); fprintf(fp, " %s", get_var_name(var, state)); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): glsl: Apply memory qualifiers to vars inside named block interfaces
Module: Mesa Branch: master Commit: 7f7f58f17f3ed547da0a00a32d9391d7ff437b83 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7f7f58f17f3ed547da0a00a32d9391d7ff437b83 Author: Eduardo Lima Mitev Date: Thu May 5 13:52:37 2016 +0200 glsl: Apply memory qualifiers to vars inside named block interfaces This is missing and memory qualifiers are currently being ignored for SSBOs. Reviewed-by: Ian Romanick --- src/compiler/glsl/ast_to_hir.cpp | 22 +++--- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp index c5cd48f..5a1fc9f 100644 --- a/src/compiler/glsl/ast_to_hir.cpp +++ b/src/compiler/glsl/ast_to_hir.cpp @@ -6963,6 +6963,16 @@ is_unsized_array_last_element(ir_variable *v) return false; } +static void +apply_memory_qualifiers(ir_variable *var, glsl_struct_field field) +{ + var->data.image_read_only = field.image_read_only; + var->data.image_write_only = field.image_write_only; + var->data.image_coherent = field.image_coherent; + var->data.image_volatile = field.image_volatile; + var->data.image_restrict = field.image_restrict; +} + ir_rvalue * ast_interface_block::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) @@ -7449,6 +7459,9 @@ ast_interface_block::hir(exec_list *instructions, } } } + + if (var->data.mode == ir_var_shader_storage) +apply_memory_qualifiers(var, fields[i]); } if (ir_variable *earlier = @@ -7523,13 +7536,8 @@ ast_interface_block::hir(exec_list *instructions, var->data.matrix_layout = fields[i].matrix_layout; } - if (var->data.mode == ir_var_shader_storage) { -var->data.image_read_only = fields[i].image_read_only; -var->data.image_write_only = fields[i].image_write_only; -var->data.image_coherent = fields[i].image_coherent; -var->data.image_volatile = fields[i].image_volatile; -var->data.image_restrict = fields[i].image_restrict; - } + if (var->data.mode == ir_var_shader_storage) +apply_memory_qualifiers(var, fields[i]); /* Examine var name here since var may get deleted in the next call */ bool var_is_gl_id = is_gl_identifier(var->name); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): nir: fix assert for wildcard pairs
Module: Mesa Branch: master Commit: 8698194313f91a3aaec2ad84c4ea5a4892cf5f1a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8698194313f91a3aaec2ad84c4ea5a4892cf5f1a Author: Thomas Hindoe Paaboel Andersen Date: Wed May 4 05:48:39 2016 +0200 nir: fix assert for wildcard pairs The assert was null checking dest_arr_parent twice. The intention seems to be to check both dest_ and src_. Added in d3636da9 Reviewed-by: Eduardo Lima Mitev --- src/compiler/nir/nir_lower_var_copies.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_lower_var_copies.c b/src/compiler/nir/nir_lower_var_copies.c index 707d5af..1a7e2ee 100644 --- a/src/compiler/nir/nir_lower_var_copies.c +++ b/src/compiler/nir/nir_lower_var_copies.c @@ -85,7 +85,7 @@ emit_copy_load_store(nir_intrinsic_instr *copy_instr, if (src_arr_parent || dest_arr_parent) { /* Wildcards had better come in matched pairs */ - assert(dest_arr_parent && dest_arr_parent); + assert(src_arr_parent && dest_arr_parent); nir_deref_array *src_arr = nir_deref_as_array(src_arr_parent->child); nir_deref_array *dest_arr = nir_deref_as_array(dest_arr_parent->child); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: remove null check before free
Module: Mesa Branch: master Commit: 76a423efe09dcaeb86badd3ec449da2ea56c5a9c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=76a423efe09dcaeb86badd3ec449da2ea56c5a9c Author: Thomas Hindoe Paaboel Andersen Date: Wed May 4 06:15:37 2016 +0200 mesa: remove null check before free Reviewed-by: Eduardo Lima Mitev --- src/mesa/main/readpix.c | 3 +-- src/mesa/main/texgetimage.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c index 882d863..1cb06c7 100644 --- a/src/mesa/main/readpix.c +++ b/src/mesa/main/readpix.c @@ -608,8 +608,7 @@ read_rgba_pixels( struct gl_context *ctx, dst, format, type); } - if (rgba) - free(rgba); + free(rgba); done_swap: /* Handle byte swapping if required */ diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index 4ac0ad4..fc3cc6b 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -557,8 +557,7 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions, } done: - if (rgba) - free(rgba); + free(rgba); } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): freedreno: remove null check before free
Module: Mesa Branch: master Commit: 3a6763f0a078b2abc9a2b0dd43efc6efe73eee30 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3a6763f0a078b2abc9a2b0dd43efc6efe73eee30 Author: Thomas Hindoe Paaboel Andersen Date: Wed May 4 06:15:36 2016 +0200 freedreno: remove null check before free Reviewed-by: Eduardo Lima Mitev --- src/gallium/drivers/freedreno/freedreno_resource.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 99affc4..4455818 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -262,8 +262,7 @@ fd_resource_transfer_unmap(struct pipe_context *pctx, pipe_resource_reference(&ptrans->resource, NULL); util_slab_free(&ctx->transfer_pool, ptrans); - if (trans->staging) - free(trans->staging); + free(trans->staging); } static void * ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): nir/print: Fix printing variable mode
Module: Mesa Branch: master Commit: 7e4628da48290f76dd0d4ddc29faf083db0d78ae URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7e4628da48290f76dd0d4ddc29faf083db0d78ae Author: Eduardo Lima Mitev Date: Fri Apr 15 10:00:05 2016 +0200 nir/print: Fix printing variable mode nir_variable_mode is currently a bitflag enum, while nir_print::print_var_decl() assumes is still a numbered list. Reviewed-by: Jason Ekstrand --- src/compiler/nir/nir_print.c | 34 +++--- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index 84e9269..229539d 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -315,6 +315,30 @@ print_constant(nir_constant *c, const struct glsl_type *type, print_state *state } } +static const char * +get_variable_mode_str(nir_variable_mode mode) +{ + switch (mode) { + case nir_var_shader_in: + return "shader_in"; + case nir_var_shader_out: + return "shader_out"; + case nir_var_uniform: + return "uniform"; + case nir_var_shader_storage: + return "shader_storage"; + case nir_var_system_value: + return "system"; + case nir_var_shared: + return "shared"; + case nir_var_param: + case nir_var_global: + case nir_var_local: + default: + return ""; + } +} + static void print_var_decl(nir_variable *var, print_state *state) { @@ -326,13 +350,9 @@ print_var_decl(nir_variable *var, print_state *state) const char *const samp = (var->data.sample) ? "sample " : ""; const char *const patch = (var->data.patch) ? "patch " : ""; const char *const inv = (var->data.invariant) ? "invariant " : ""; - const char *const mode[] = { "shader_in ", "shader_out ", "", "", -"uniform ", "shader_storage ", "shared ", -"system "}; - - fprintf(fp, "%s%s%s%s%s%s ", - cent, samp, patch, inv, mode[var->data.mode], - glsl_interp_qualifier_name(var->data.interpolation)); + fprintf(fp, "%s%s%s%s%s %s ", + cent, samp, patch, inv, get_variable_mode_str(var->data.mode), + glsl_interp_qualifier_name(var->data.interpolation)); glsl_print_type(var->type, fp); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965: Add autogenerated 'brw_nir_trig_workarounds.c' to gitignore
Module: Mesa Branch: master Commit: ea8a65f503f05404d923a2a076064c3ffe6660aa URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ea8a65f503f05404d923a2a076064c3ffe6660aa Author: Eduardo Lima Mitev Date: Tue Apr 12 10:11:35 2016 +0200 i965: Add autogenerated 'brw_nir_trig_workarounds.c' to gitignore Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/dri/i965/.gitignore b/src/mesa/drivers/dri/i965/.gitignore index 8eb9f4e..70aae3f 100644 --- a/src/mesa/drivers/dri/i965/.gitignore +++ b/src/mesa/drivers/dri/i965/.gitignore @@ -1,3 +1,4 @@ +brw_nir_trig_workarounds.c i965_symbols_test test_eu_compact test_vec4_copy_propagation ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): compiler/glsl: allow sequence op as a const expr in gles 1.0
Module: Mesa Branch: master Commit: 43c6f3f82f62f28dc97d195750ba25c88051b64e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=43c6f3f82f62f28dc97d195750ba25c88051b64e Author: Lars Hamre Date: Wed Mar 23 10:14:23 2016 -0400 compiler/glsl: allow sequence op as a const expr in gles 1.0 Allow the sequence operator to be a constant expression in GLSL ES versions prior to GLSL ES 3.0 Fixes the following piglit test: /all/spec/glsl-es-1.0/compiler/array-sized-by-sequence-in-parenthesis.vert This is similar to the logic from process_initializer() which performs the same check for constant variable initialization with sequence operators. v2: Fixed regression pointed out by Eduardo Lima Mitev Signed-off-by: Lars Hamre Reviewed-by: Eduardo Lima Mitev --- src/compiler/glsl/ast_to_hir.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp index 5262bd8..35def8e 100644 --- a/src/compiler/glsl/ast_to_hir.cpp +++ b/src/compiler/glsl/ast_to_hir.cpp @@ -2125,7 +2125,9 @@ process_array_size(exec_node *node, } ir_constant *const size = ir->constant_expression_value(); - if (size == NULL || array_size->has_sequence_subexpression()) { + if (size == NULL || + (state->is_version(120, 300) && +array_size->has_sequence_subexpression())) { _mesa_glsl_error(& loc, state, "array size must be a " "constant valued expression"); return 0; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): Update docs to advertise new support for ARB_internalformat_query2
Module: Mesa Branch: master Commit: 47392011c057e078848d0be84aaba540ef84e8c7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=47392011c057e078848d0be84aaba540ef84e8c7 Author: Eduardo Lima Mitev Date: Thu Mar 3 15:43:01 2016 +0100 Update docs to advertise new support for ARB_internalformat_query2 Support in Mesa main and i965 has just been added. v2: Include note in 'New Features' of docs/relnotes/11.3.0.html. Reviewed-by: Ilia Mirkin --- docs/GL3.txt | 2 +- docs/relnotes/11.3.0.html | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/GL3.txt b/docs/GL3.txt index d141c22..02dc6ea 100644 --- a/docs/GL3.txt +++ b/docs/GL3.txt @@ -158,7 +158,7 @@ GL 4.3, GLSL 4.30: GL_ARB_explicit_uniform_location DONE (all drivers that support GLSL) GL_ARB_fragment_layer_viewport DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe) GL_ARB_framebuffer_no_attachmentsDONE (i965) - GL_ARB_internalformat_query2 in progress (elima) + GL_ARB_internalformat_query2 DONE (i965) GL_ARB_invalidate_subdataDONE (all drivers) GL_ARB_multi_draw_indirect DONE (i965, nvc0, r600, radeonsi, llvmpipe, softpipe) GL_ARB_program_interface_query DONE (all drivers) diff --git a/docs/relnotes/11.3.0.html b/docs/relnotes/11.3.0.html index fa65083..99445c2 100644 --- a/docs/relnotes/11.3.0.html +++ b/docs/relnotes/11.3.0.html @@ -44,6 +44,7 @@ Note: some of the new features are only available with certain drivers. +GL_ARB_internalformat_query2 on i965 GL_OES_texture_border_clamp and GL_EXT_texture_border_clamp on all drivers that support GL_ARB_texture_border_clamp GL_OES_shader_image_atomic on all drivers that support GL_ARB_shader_image_load_store ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): 65 new commits
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4f028bfcc048d7cbd7a7239e9f61b4d7b708aebb Author: Antia Puentes Date: Wed Oct 21 15:25:30 2015 +0200 i965: Enable the ARB_internalformat_query2 extension Reviewed-by: Dave Airlie URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cbbdf8612d784faa0928208fd6599c6add2d0e48 Author: Eduardo Lima Mitev Date: Tue Dec 22 17:16:50 2015 +0100 i965/formatquery: Add support for INTERNALFORMAT_PREFERRED query This pname is tricky. The spec states that an internal format should be returned, that is compatible with the passed internal format, and has at least the same precision. There is no clear API to resolve this. The closest we have (and what other drivers (i.e, NVidia proprietary) do, is to return the same internal format given as parameter. But we validate first that the passed internal format is supported by i965. To check for support, we have the TextureFormatSupported map'. But this map expects a 'mesa_format', which takes a format+typen. So, we must first "come up" with a generic type that is suited for this internal format, then get a mesa_format, and then do the validation. The cleanest solution here is to add a method that does exactly what the spec wants: a driver's preferred internal format from a given internal format. But at this point we lack a clear view of what defines this preference, and also there seems to be no API for it. Reviewed-by: Dave Airlie URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e064f43485b63053f5786f680407f15bc203763f Author: Eduardo Lima Mitev Date: Wed Feb 3 10:57:10 2016 +0100 mesa/glformats: Consider DEPTH/STENCIL when resolving a mesa_format _mesa_format_from_format_and_type() is currently not considering DEPTH and STENCIL formats, which are not array formats and are not handled anywhere. This patch adds cases for common combinations of DEPTH/STENCIL format and types. Reviewed-by: Dave Airlie URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ec299602a6a1db209e8e93c0853ccad1eb4ffa72 Author: Eduardo Lima Mitev Date: Tue Dec 22 19:33:57 2015 +0100 mesa/formatquery: Add (GET_)TEXTURE_IMAGE_TYPE pnames These basically reuse the default implementation of GL_READ_PIXELS_TYPE. Reviewed-by: Dave Airlie URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=23f94146c987c380bcdebb0d787dc71e808afc27 Author: Eduardo Lima Mitev Date: Tue Dec 22 19:19:32 2015 +0100 mesa/formatquery: Add (GET_)TEXTURE_IMAGE_FORMAT pnames Reviewed-by: Dave Airlie URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=020671f2a3d47ff35e9937b4db3fa09df6f6d488 Author: Eduardo Lima Mitev Date: Tue Dec 22 18:52:38 2015 +0100 mesa/formatquery: Add READ_PIXELS_TYPE pname We call the driver to provide its preferred type, but also provide a default implementation that selects a generic type based on the passed internal format. Reviewed-by: Dave Airlie URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bec286f7246bedba9f7f34185f2e1e29befec3ab Author: Eduardo Lima Mitev Date: Tue Dec 22 18:38:06 2015 +0100 mesa/formatquery: Add READ_PIXELS_FORMAT pname Reviewed-by: Dave Airlie URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=09550c16a51e89dbf64b0864d3fb4ddb6accac52 Author: Eduardo Lima Mitev Date: Tue Dec 22 18:20:57 2015 +0100 mesa/formatquery: Add support for READ_PIXELS query This is supported since very early version of OpenGL, but we still call the driver to give it the opportunity to report caveat or no support. Reviewed-by: Dave Airlie URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8d7696f6380c38085029fff0eb00c3c18ea8e017 Author: Alejandro Piñeiro Date: Tue Dec 22 20:06:19 2015 +0100 mesa/formatquery: added FILTER pname support It discards out the targets and internalformats that explicitly mention (per-spec) that doesn't support filter types other than NEAREST or NEAREST_MIPMAP_NEAREST. Those are: * Texture buffers target * Multisample targets * Any integer internalformat For the case of multisample targets, it was used the existing method _mesa_target_allows_setting_sampler_parameter. This would scalate better in the future if new targets appear that doesn't allow to set sampler parameters. We consider RENDERBUFFER to support LINEAR filters, because although it doesn't support this filter for sampling, you can set LINEAR on a blit operation using glBlitFramebuffer. Reviewed-by: Dave Airlie URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a8736a2567057c0cb3cdd673743d9cc8b562b288 Author: Alejandro Piñeiro Date: Tue Dec 22 20:04:
Mesa (master): docs: Update GL3.txt to add ARB_internalformat_query2
Module: Mesa Branch: master Commit: 27a88a947c78c9af5eaeb6587fb5211057931d8c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=27a88a947c78c9af5eaeb6587fb5211057931d8c Author: Eduardo Lima Mitev Date: Thu Nov 26 21:57:40 2015 +0100 docs: Update GL3.txt to add ARB_internalformat_query2 Added to OpenGL 4.3 section, tagged as 'in progress (elima)'. See https://bugs.freedesktop.org/show_bug.cgi?id=92687. Thanks to Thomas H.P. Andersen for remainding me about this. v1: - Update the already existing entry in section 4.3 instead (Ilia Mirkin). - Added my BZ nickname as contact person (Felix Schwarz). Reviewed-by: Ilia Mirkin --- docs/GL3.txt |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/GL3.txt b/docs/GL3.txt index ad6b95e..acf1166 100644 --- a/docs/GL3.txt +++ b/docs/GL3.txt @@ -158,7 +158,7 @@ GL 4.3, GLSL 4.30: GL_ARB_explicit_uniform_location DONE (all drivers that support GLSL) GL_ARB_fragment_layer_viewport DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe) GL_ARB_framebuffer_no_attachmentsDONE (i965) - GL_ARB_internalformat_query2 not started + GL_ARB_internalformat_query2 in progress (elima) GL_ARB_invalidate_subdataDONE (all drivers) GL_ARB_multi_draw_indirect DONE (i965, nvc0, r600, radeonsi, llvmpipe, softpipe) GL_ARB_program_interface_query DONE (all drivers) ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965: Return the correct value type from brw_compile_gs()
Module: Mesa Branch: master Commit: 252b143e9e8ca0b98143c237f14cb0b548ffd510 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=252b143e9e8ca0b98143c237f14cb0b548ffd510 Author: Eduardo Lima Mitev Date: Tue Nov 17 09:49:43 2015 +0100 i965: Return the correct value type from brw_compile_gs() brw_compile_gs() should return a pointer to unsigned, but it is returning the bool 'false' at some point, hence annoying us with a compiler warning: In function 'const unsigned int* brw::brw_compile_gs(const brw_compiler*, void*, void*, const brw_gs_prog_key*, brw_gs_prog_data*, const nir_shader*, gl_shader_program*, int, unsigned int*, char**)': brw_vec4_gs_visitor.cpp:776:14: warning: converting 'false' to pointer type 'const unsigned int*' [-Wconversion-null] return false; ^ Reviewed-by: Jordan Justen --- src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp index 81353ae..0c49865 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp @@ -773,7 +773,7 @@ brw_compile_gs(const struct brw_compiler *compiler, void *log_data, if (compiler->devinfo->gen == 6) max_output_size_bytes = GEN6_MAX_GS_URB_ENTRY_SIZE_BYTES; if (output_size_bytes > max_output_size_bytes) - return false; + return NULL; /* URB entry sizes are stored as a multiple of 64 bytes in gen7+ and ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): util: Add list_is_singular() helper function
Module: Mesa Branch: master Commit: fb3b5669cee85781b603f612228387e9a2e4120f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fb3b5669cee85781b603f612228387e9a2e4120f Author: Eduardo Lima Mitev Date: Fri Oct 23 16:31:41 2015 +0200 util: Add list_is_singular() helper function Returns whether the list has exactly one element. Reviewed-by: Matt Turner --- src/util/list.h |8 1 file changed, 8 insertions(+) diff --git a/src/util/list.h b/src/util/list.h index b98ce59..066f9b8 100644 --- a/src/util/list.h +++ b/src/util/list.h @@ -99,6 +99,14 @@ static inline bool list_empty(struct list_head *list) return list->next == list; } +/** + * Returns whether the list has exactly one element. + */ +static inline bool list_is_singular(const struct list_head *list) +{ + return list->next != NULL && list->next->next == list; +} + static inline unsigned list_length(struct list_head *list) { struct list_head *node; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): nir/nir_opt_peephole_ffma: Move this lowering pass to the i965 driver
Module: Mesa Branch: master Commit: 94ff35204dba0ddbd7f5c4342206c8acba22d32f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=94ff35204dba0ddbd7f5c4342206c8acba22d32f Author: Eduardo Lima Mitev Date: Thu Oct 22 15:25:23 2015 +0200 nir/nir_opt_peephole_ffma: Move this lowering pass to the i965 driver Because the next patch will add an optimization that is specific to i965, we want to move this loweing pass to that driver altogether. This is safe because i965 is the only consumer. Reviewed-by: Jason Ekstrand --- src/glsl/Makefile.sources |1 - src/glsl/nir/nir.h |1 - src/mesa/drivers/dri/i965/Makefile.sources |1 + src/mesa/drivers/dri/i965/brw_nir.c|2 +- src/mesa/drivers/dri/i965/brw_nir.h|2 ++ .../drivers/dri/i965/brw_nir_opt_peephole_ffma.c} | 12 ++-- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources index 78d295b..d4b02c1 100644 --- a/src/glsl/Makefile.sources +++ b/src/glsl/Makefile.sources @@ -67,7 +67,6 @@ NIR_FILES = \ nir/nir_opt_dead_cf.c \ nir/nir_opt_gcm.c \ nir/nir_opt_global_to_local.c \ - nir/nir_opt_peephole_ffma.c \ nir/nir_opt_peephole_select.c \ nir/nir_opt_remove_phis.c \ nir/nir_opt_undef.c \ diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index 13ebbca..4ed2cbd 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -2029,7 +2029,6 @@ bool nir_opt_dead_cf(nir_shader *shader); void nir_opt_gcm(nir_shader *shader); bool nir_opt_peephole_select(nir_shader *shader); -bool nir_opt_peephole_ffma(nir_shader *shader); bool nir_opt_remove_phis(nir_shader *shader); diff --git a/src/mesa/drivers/dri/i965/Makefile.sources b/src/mesa/drivers/dri/i965/Makefile.sources index 434583d..f5e84cb 100644 --- a/src/mesa/drivers/dri/i965/Makefile.sources +++ b/src/mesa/drivers/dri/i965/Makefile.sources @@ -46,6 +46,7 @@ i965_compiler_FILES = \ brw_nir.h \ brw_nir.c \ brw_nir_analyze_boolean_resolves.c \ + brw_nir_opt_peephole_ffma.c \ brw_nir_uniforms.cpp \ brw_packed_float.c \ brw_predicated_break.cpp \ diff --git a/src/mesa/drivers/dri/i965/brw_nir.c b/src/mesa/drivers/dri/i965/brw_nir.c index dece208..fe5cad4 100644 --- a/src/mesa/drivers/dri/i965/brw_nir.c +++ b/src/mesa/drivers/dri/i965/brw_nir.c @@ -293,7 +293,7 @@ brw_create_nir(struct brw_context *brw, if (brw->gen >= 6) { /* Try and fuse multiply-adds */ - nir_opt_peephole_ffma(nir); + brw_nir_opt_peephole_ffma(nir); nir_validate_shader(nir); } diff --git a/src/mesa/drivers/dri/i965/brw_nir.h b/src/mesa/drivers/dri/i965/brw_nir.h index b4a6dc0..e7c9368 100644 --- a/src/mesa/drivers/dri/i965/brw_nir.h +++ b/src/mesa/drivers/dri/i965/brw_nir.h @@ -94,6 +94,8 @@ void brw_nir_setup_glsl_uniforms(nir_shader *shader, void brw_nir_setup_arb_uniforms(nir_shader *shader, struct gl_program *prog, struct brw_stage_prog_data *stage_prog_data); +bool brw_nir_opt_peephole_ffma(nir_shader *shader); + #ifdef __cplusplus } #endif diff --git a/src/glsl/nir/nir_opt_peephole_ffma.c b/src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c similarity index 96% rename from src/glsl/nir/nir_opt_peephole_ffma.c rename to src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c index 4f0f0da..a8448e7 100644 --- a/src/glsl/nir/nir_opt_peephole_ffma.c +++ b/src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c @@ -25,7 +25,7 @@ * */ -#include "nir.h" +#include "brw_nir.h" /* * Implements a small peephole optimization that looks for a multiply that @@ -134,7 +134,7 @@ get_mul_for_src(nir_alu_src *src, int num_components, } static bool -nir_opt_peephole_ffma_block(nir_block *block, void *void_state) +brw_nir_opt_peephole_ffma_block(nir_block *block, void *void_state) { struct peephole_ffma_state *state = void_state; @@ -237,7 +237,7 @@ nir_opt_peephole_ffma_block(nir_block *block, void *void_state) } static bool -nir_opt_peephole_ffma_impl(nir_function_impl *impl) +brw_nir_opt_peephole_ffma_impl(nir_function_impl *impl) { struct peephole_ffma_state state; @@ -245,7 +245,7 @@ nir_opt_peephole_ffma_impl(nir_function_impl *impl) state.impl = impl; state.progress = false; - nir_foreach_block(impl, nir_opt_peephole_ffma_block, &state); + nir_foreach_block(impl, brw_nir_opt_peephole_ffma_block, &state); if (state.progress) nir_metadata_preserve(impl, nir_metadata_block_index | @@ -255,13 +255,13 @@ nir_opt_peephole_ffma_impl(nir_function_impl *impl) } bool -nir_opt_peephole_ffma(nir_shader *shader) +brw_nir_opt_peephole_ffma(nir_shader *shader) { bool progress = false; nir_foreach_overload(shader, ove
Mesa (master): i965/nir/opt_peephole_ffma: Bypass fusion if any operand of fadd and fmul is a const
Module: Mesa Branch: master Commit: de51676b410ff3ccab1df765f8eee15126c9de4c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=de51676b410ff3ccab1df765f8eee15126c9de4c Author: Eduardo Lima Mitev Date: Thu Oct 22 15:32:13 2015 +0200 i965/nir/opt_peephole_ffma: Bypass fusion if any operand of fadd and fmul is a const When both fadd and fmul instructions have at least one operand that is a constant and it is only used once, the total number of instructions can be reduced from 3 (1 ffma + 2 load_const) to 2 (1 fmul + 1 fadd); because the constants will be progagated as immediate operands of fmul and fadd. This patch detects these situations and prevents fusing fmul+fadd into ffma. Shader-db results on i965 Haswell: total instructions in shared programs: 6235835 -> 6225895 (-0.16%) instructions in affected programs: 1124094 -> 1114154 (-0.88%) total loops in shared programs:1979 -> 1979 (0.00%) helped:7612 HURT: 843 GAINED:4 LOST: 0 Reviewed-by: Jason Ekstrand --- .../drivers/dri/i965/brw_nir_opt_peephole_ffma.c | 31 1 file changed, 31 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c b/src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c index a8448e7..5603129 100644 --- a/src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c +++ b/src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c @@ -133,6 +133,28 @@ get_mul_for_src(nir_alu_src *src, int num_components, return alu; } +/** + * Given a list of (at least two) nir_alu_src's, tells if any of them is a + * constant value and is used only once. + */ +static bool +any_alu_src_is_a_constant(nir_alu_src srcs[]) +{ + for (unsigned i = 0; i < 2; i++) { + if (srcs[i].src.ssa->parent_instr->type == nir_instr_type_load_const) { + nir_load_const_instr *load_const = +nir_instr_as_load_const (srcs[i].src.ssa->parent_instr); + + if (list_is_singular(&load_const->def.uses) && + list_empty(&load_const->def.if_uses)) { +return true; + } + } + } + + return false; +} + static bool brw_nir_opt_peephole_ffma_block(nir_block *block, void *void_state) { @@ -183,6 +205,15 @@ brw_nir_opt_peephole_ffma_block(nir_block *block, void *void_state) mul_src[0] = mul->src[0].src.ssa; mul_src[1] = mul->src[1].src.ssa; + /* If any of the operands of the fmul and any of the fadd is a constant, + * we bypass because it will be more efficient as the constants will be + * propagated as operands, potentially saving two load_const instructions. + */ + if (any_alu_src_is_a_constant(mul->src) && + any_alu_src_is_a_constant(add->src)) { + continue; + } + if (abs) { for (unsigned i = 0; i < 2; i++) { nir_alu_instr *abs = nir_alu_instr_create(state->mem_ctx, ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965/vec4/nir: Remove all "this->" snippets
Module: Mesa Branch: master Commit: 6ba291db4ba4f03ac94560eaae861bc162ac838e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6ba291db4ba4f03ac94560eaae861bc162ac838e Author: Eduardo Lima Mitev Date: Fri Sep 18 10:30:12 2015 +0200 i965/vec4/nir: Remove all "this->" snippets For consistency, either we have all class members dereferenced, or none. In this case, very few are so lets get rid of them all. Reviewed-by: Timothy Arceri Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_vec4_nir.cpp | 31 ++-- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp index 482fce2..20c063d 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp @@ -58,25 +58,24 @@ vec4_visitor::nir_setup_system_value_intrinsic(nir_intrinsic_instr *instr) unreachable("should be lowered by lower_vertex_id()."); case nir_intrinsic_load_vertex_id_zero_base: - reg = &this->nir_system_values[SYSTEM_VALUE_VERTEX_ID_ZERO_BASE]; + reg = &nir_system_values[SYSTEM_VALUE_VERTEX_ID_ZERO_BASE]; if (reg->file == BAD_FILE) - *reg = -*this->make_reg_for_system_value(SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, - glsl_type::int_type); + *reg = *make_reg_for_system_value(SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, + glsl_type::int_type); break; case nir_intrinsic_load_base_vertex: - reg = &this->nir_system_values[SYSTEM_VALUE_BASE_VERTEX]; + reg = &nir_system_values[SYSTEM_VALUE_BASE_VERTEX]; if (reg->file == BAD_FILE) - *reg = *this->make_reg_for_system_value(SYSTEM_VALUE_BASE_VERTEX, - glsl_type::int_type); + *reg = *make_reg_for_system_value(SYSTEM_VALUE_BASE_VERTEX, + glsl_type::int_type); break; case nir_intrinsic_load_instance_id: - reg = &this->nir_system_values[SYSTEM_VALUE_INSTANCE_ID]; + reg = &nir_system_values[SYSTEM_VALUE_INSTANCE_ID]; if (reg->file == BAD_FILE) - *reg = *this->make_reg_for_system_value(SYSTEM_VALUE_INSTANCE_ID, - glsl_type::int_type); + *reg = *make_reg_for_system_value(SYSTEM_VALUE_INSTANCE_ID, + glsl_type::int_type); break; default: @@ -142,7 +141,7 @@ vec4_visitor::nir_setup_uniforms(nir_shader *shader) } assert(uniforms < uniform_array_size); - this->uniform_size[uniforms] = type_size_vec4(var->type); + uniform_size[uniforms] = type_size_vec4(var->type); if (strncmp(var->name, "gl_", 3) == 0) nir_setup_builtin_uniform(var); @@ -158,7 +157,7 @@ vec4_visitor::nir_setup_uniforms(nir_shader *shader) strcmp(var->name, "parameters") == 0); assert(uniforms < uniform_array_size); - this->uniform_size[uniforms] = type_size_vec4(var->type); + uniform_size[uniforms] = type_size_vec4(var->type); struct gl_program_parameter_list *plist = prog->Parameters; for (unsigned p = 0; p < plist->NumParameters; p++) { @@ -243,10 +242,10 @@ vec4_visitor::nir_setup_builtin_uniform(nir_variable *var) * ParameterValues directly, since unlike brw_fs.cpp, we never * add new state references during compile. */ - int index = _mesa_add_state_reference(this->prog->Parameters, + int index = _mesa_add_state_reference(prog->Parameters, (gl_state_index *)slots[i].tokens); gl_constant_value *values = - &this->prog->Parameters->ParameterValues[index][0]; + &prog->Parameters->ParameterValues[index][0]; assert(uniforms < uniform_array_size); @@ -254,7 +253,7 @@ vec4_visitor::nir_setup_builtin_uniform(nir_variable *var) stage_prog_data->param[uniforms * 4 + j] = &values[GET_SWZ(slots[i].swizzle, j)]; - this->uniform_vector_size[uniforms] = + uniform_vector_size[uniforms] = (var->type->is_scalar() || var->type->is_vector() || var->type->is_matrix() ? var->type->vector_elements : 4); @@ -344,7 +343,7 @@ vec4_visitor::nir_emit_block(nir_block *block) void vec4_visitor::nir_emit_instr(nir_instr *instr) { - this->base_ir = instr; + base_ir = instr; switch (instr->type) { case nir_instr_type_load_const: ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965/vec4: check writemask when bailing out at register coalesce
Module: Mesa Branch: master Commit: d4e29af2344c06490913efc35430f93a966061bb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d4e29af2344c06490913efc35430f93a966061bb Author: Alejandro Piñeiro Date: Fri Sep 11 12:21:13 2015 +0200 i965/vec4: check writemask when bailing out at register coalesce opt_register_coalesce stopped to check previous instructions to coalesce with if somebody else was writing on the same destination. This can be optimized to check if somebody else was writing to the same channels of the same destination using the writemask. Shader DB results (taking into account only vec4): total instructions in shared programs: 1781593 -> 1734957 (-2.62%) instructions in affected programs: 1238390 -> 1191754 (-3.77%) helped:12782 HURT: 0 GAINED:0 LOST: 0 v2: removed some parenthesis, fixed indentation, as suggested by Matt Turner v3: added brackets, for consistency, as suggested by Eduardo Lima Reviewed-by: Matt Turner --- src/mesa/drivers/dri/i965/brw_vec4.cpp | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp index 893ff35..c4da1a1 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp @@ -1090,11 +1090,13 @@ vec4_visitor::opt_register_coalesce() if (interfered) break; - /* If somebody else writes our destination here, we can't coalesce - * before that. + /* If somebody else writes the same channels of our destination here, + * we can't coalesce before that. */ - if (inst->dst.in_range(scan_inst->dst, scan_inst->regs_written)) - break; + if (inst->dst.in_range(scan_inst->dst, scan_inst->regs_written) && + (inst->dst.writemask & scan_inst->dst.writemask) != 0) { +break; + } /* Check for reads of the register we're trying to coalesce into. We * can't go rewriting instructions above that to put some other value ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Validate target before resolving tex obj in glTex( ture)SubImageXD
Module: Mesa Branch: master Commit: 5d64cae8427b090c42d6d38da7fb474b3ddd4eb0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5d64cae8427b090c42d6d38da7fb474b3ddd4eb0 Author: Eduardo Lima Mitev Date: Wed Jul 29 16:01:26 2015 +0200 mesa: Validate target before resolving tex obj in glTex(ture)SubImageXD Currently, glTexSubImageXD attempt to resolve the texture object (by calling _mesa_get_current_tex_object()) before validating the given target. However, that method explicitly states that target must have been validated before calling it, so it never returns a user error. The target validation occurs later when texsubimage_error_check() is called. This patch reorganizes target validation, taking it out from the error check function and into a point before the texture object is resolved. Reviewed-by: Ian Romanick Cc: 10.6 --- src/mesa/main/teximage.c | 29 ++--- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 841ec36..115dee6 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -2487,13 +2487,6 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions, return GL_TRUE; } - /* check target (proxies not allowed) */ - if (!legal_texsubimage_target(ctx, dimensions, target, dsa)) { - _mesa_error(ctx, GL_INVALID_ENUM, "%s(target=%s)", - callerName, _mesa_enum_to_string(target)); - return GL_TRUE; - } - /* level check */ if (level < 0 || level >= _mesa_max_texture_levels(ctx, target)) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(level=%d)", callerName, level); @@ -3522,14 +3515,6 @@ _mesa_texture_sub_image(struct gl_context *ctx, GLuint dims, { FLUSH_VERTICES(ctx, 0); - /* check target (proxies not allowed) */ - if (!legal_texsubimage_target(ctx, dims, target, dsa)) { - _mesa_error(ctx, GL_INVALID_ENUM, "glTex%sSubImage%uD(target=%s)", - dsa ? "ture" : "", - dims, _mesa_enum_to_string(target)); - return; - } - if (ctx->NewState & _NEW_PIXEL) _mesa_update_state(ctx); @@ -3579,6 +3564,13 @@ texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level, struct gl_texture_object *texObj; struct gl_texture_image *texImage; + /* check target (proxies not allowed) */ + if (!legal_texsubimage_target(ctx, dims, target, false)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage%uD(target=%s)", + dims, _mesa_enum_to_string(target)); + return; + } + texObj = _mesa_get_current_tex_object(ctx, target); if (!texObj) return; @@ -3639,6 +3631,13 @@ texturesubimage(struct gl_context *ctx, GLuint dims, return; } + /* check target (proxies not allowed) */ + if (!legal_texsubimage_target(ctx, dims, texObj->Target, true)) { + _mesa_error(ctx, GL_INVALID_ENUM, "%s(target=%s)", + callerName, _mesa_enum_to_string(texObj->Target)); + return; + } + if (texsubimage_error_check(ctx, dims, texObj, texObj->Target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Add missing check of format and type in glTexSubImageXD on GLES 3.0
Module: Mesa Branch: master Commit: 03b7221dbb93e2439f30b2e0918f6215eb741979 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=03b7221dbb93e2439f30b2e0918f6215eb741979 Author: Eduardo Lima Mitev Date: Wed Jul 29 16:01:27 2015 +0200 mesa: Add missing check of format and type in glTexSubImageXD on GLES 3.0 Argument validation for glTexSubImageXD is missing a check of format and type against texture object's internal format when profile is OpenGL-ES 3.0+. This patch also groups together all format and type checks on GLES into a new function texture_format_error_check_gles(), to factorize similar code in texture_format_error_check(). Fixes 2 dEQP tests: * dEQP-GLES3.functional.negative_api.texture.texsubimage2d * dEQP-GLES3.functional.negative_api.texture.texsubimage3d Reviewed-by: Ian Romanick Reviewed-by: Brian Paul --- src/mesa/main/teximage.c | 116 +++--- 1 file changed, 69 insertions(+), 47 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index d19ad64..fc69387 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -2089,6 +2089,53 @@ texture_formats_agree(GLenum internalFormat, } /** + * Test the combination of format, type and internal format arguments of + * different texture operations on GLES. + * + * \param ctx GL context. + * \param format pixel data format given by the user. + * \param type pixel data type given by the user. + * \param internalFormat internal format given by the user. + * \param dimensions texture image dimensions (must be 1, 2 or 3). + * \param callerName name of the caller function to print in the error message + * + * \return true if a error is found, false otherwise + * + * Currently, it is used by texture_error_check() and texsubimage_error_check(). + */ +static bool +texture_format_error_check_gles(struct gl_context *ctx, GLenum format, +GLenum type, GLenum internalFormat, +GLuint dimensions, const char *callerName) +{ + GLenum err; + + if (_mesa_is_gles3(ctx)) { + err = _mesa_es3_error_check_format_and_type(ctx, format, type, + internalFormat); + if (err != GL_NO_ERROR) { + _mesa_error(ctx, err, + "%s(format = %s, type = %s, internalformat = %s)", + callerName, _mesa_enum_to_string(format), + _mesa_enum_to_string(type), + _mesa_enum_to_string(internalFormat)); + return true; + } + } + else { + err = _mesa_es_error_check_format_and_type(format, type, dimensions); + if (err != GL_NO_ERROR) { + _mesa_error(ctx, err, "%s(format = %s, type = %s)", + callerName, _mesa_enum_to_string(format), + _mesa_enum_to_string(type)); + return true; + } + } + + return false; +} + +/** * Test the glTexImage[123]D() parameters for errors. * * \param ctx GL context. @@ -2159,32 +2206,10 @@ texture_error_check( struct gl_context *ctx, * Formats and types that require additional extensions (e.g., GL_FLOAT * requires GL_OES_texture_float) are filtered elsewhere. */ - - if (_mesa_is_gles(ctx)) { - if (_mesa_is_gles3(ctx)) { - err = _mesa_es3_error_check_format_and_type(ctx, format, type, - internalFormat); - } else { - if (format != internalFormat) { -_mesa_error(ctx, GL_INVALID_OPERATION, -"glTexImage%dD(format = %s, internalFormat = %s)", -dimensions, -_mesa_enum_to_string(format), -_mesa_enum_to_string(internalFormat)); -return GL_TRUE; - } - - err = _mesa_es_error_check_format_and_type(format, type, dimensions); - } - if (err != GL_NO_ERROR) { - _mesa_error(ctx, err, - "glTexImage%dD(format = %s, type = %s, internalFormat = %s)", - dimensions, - _mesa_enum_to_string(format), - _mesa_enum_to_string(type), - _mesa_enum_to_string(internalFormat)); - return GL_TRUE; - } + if (_mesa_is_gles(ctx) && + texture_format_error_check_gles(ctx, format, type, internalFormat, + dimensions, "glTexImage%dD")) { + return GL_TRUE; } /* Check internalFormat */ @@ -2493,19 +2518,12 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions, return GL_TRUE; } - /* OpenGL ES 1.x and OpenGL ES 2.0 impose additional restrictions on the -* combinations of format and type that can be used. Formats and types -* that require additional extensions (e.g., GL_FLOAT requires -* GL_OES_textu
Mesa (master): mesa: Fix error returned by glCopyTexImage2D() upon an invalid internal format
Module: Mesa Branch: master Commit: 4b07e9a033ddb6733eba206b5bd47a2373756f7d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4b07e9a033ddb6733eba206b5bd47a2373756f7d Author: Eduardo Lima Mitev Date: Wed Jul 29 16:01:28 2015 +0200 mesa: Fix error returned by glCopyTexImage2D() upon an invalid internal format Page 161 of the OpenGL-ES 3.1 (PDF) spec, and page 207 of the OpenGL 4.5 (PDF), both on section '8.6. ALTERNATE TEXTURE IMAGE SPECIFICATION COMMANDS', states: "An INVALID_ENUM error is generated if an invalid value is specified for internalformat". It is currently returning INVALID_OPERATION error because _mesa_get_read_renderbuffer_for_format() is called before the internalformat argument has been validated. To fix this, we move this call down the validation process, after _mesa_base_tex_format() has been called. _mesa_base_tex_format() effectively serves as a validator for the internal format. Fixes 1 dEQP test: * dEQP-GLES3.functional.negative_api.texture.copyteximage2d_invalid_format Fixes 1 piglit test: * spec@oes_compressed_etc1_rgb8_texture@basic Reviewed-by: Ian Romanick Cc: 10.6 --- src/mesa/main/teximage.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 115dee6..d19ad64 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -2630,13 +2630,6 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions, return GL_TRUE; } - rb = _mesa_get_read_renderbuffer_for_format(ctx, internalFormat); - if (rb == NULL) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCopyTexImage%dD(read buffer)", dimensions); - return GL_TRUE; - } - /* OpenGL ES 1.x and OpenGL ES 2.0 impose additional restrictions on the * internalFormat. */ @@ -2649,7 +2642,7 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions, case GL_LUMINANCE_ALPHA: break; default: - _mesa_error(ctx, GL_INVALID_VALUE, + _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexImage%dD(internalFormat=%s)", dimensions, _mesa_enum_to_string(internalFormat)); return GL_TRUE; @@ -2658,12 +2651,19 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions, baseFormat = _mesa_base_tex_format(ctx, internalFormat); if (baseFormat < 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, + _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexImage%dD(internalFormat=%s)", dimensions, _mesa_enum_to_string(internalFormat)); return GL_TRUE; } + rb = _mesa_get_read_renderbuffer_for_format(ctx, internalFormat); + if (rb == NULL) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexImage%dD(read buffer)", dimensions); + return GL_TRUE; + } + rb_internal_format = rb->InternalFormat; rb_base_format = _mesa_base_tex_format(ctx, rb->InternalFormat); if (_mesa_is_color_format(internalFormat)) { ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Fix errors values returned by glShaderBinary()
Module: Mesa Branch: master Commit: b38a50f1e3edae6079c91f73a8d9c63a2dbf512a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b38a50f1e3edae6079c91f73a8d9c63a2dbf512a Author: Eduardo Lima Mitev Date: Wed Jul 29 16:01:23 2015 +0200 mesa: Fix errors values returned by glShaderBinary() Page 68, section 7.2 'Shader Binaries" of the of the OpenGL ES 3.1, and page 88 of the OpenGL 4.5 specs state: "An INVALID_VALUE error is generated if count or length is negative. An INVALID_ENUM error is generated if binaryformat is not a supported format returned in SHADER_BINARY_FORMATS." Currently, an INVALID_OPERATION error is returned for all cases. Fixes 1 dEQP test: * dEQP-GLES3.functional.negative_api.shader.shader_binary Reviewed-by: Ian Romanick Cc: 10.6 --- src/mesa/main/shaderapi.c | 17 ++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index b702dcd..5b28a2c 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1793,12 +1793,23 @@ _mesa_ShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length) { GET_CURRENT_CONTEXT(ctx); - (void) n; (void) shaders; (void) binaryformat; (void) binary; - (void) length; - _mesa_error(ctx, GL_INVALID_OPERATION, "glShaderBinary"); + + /* Page 68, section 7.2 'Shader Binaries" of the of the OpenGL ES 3.1, and +* page 88 of the OpenGL 4.5 specs state: +* +* "An INVALID_VALUE error is generated if count or length is negative. +* An INVALID_ENUM error is generated if binaryformat is not a supported +* format returned in SHADER_BINARY_FORMATS." +*/ + if (n < 0 || length < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glShaderBinary(count or length < 0)"); + return; + } + + _mesa_error(ctx, GL_INVALID_ENUM, "glShaderBinary(format)"); } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Return INVALID_ENUM in glClearBufferiv() when buffer is not color or stencil
Module: Mesa Branch: master Commit: c00d093c8f247c41f9122143c49ffa93865a0ded URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c00d093c8f247c41f9122143c49ffa93865a0ded Author: Eduardo Lima Mitev Date: Tue Feb 10 16:40:40 2015 +0100 mesa: Return INVALID_ENUM in glClearBufferiv() when buffer is not color or stencil Page 497 of the PDF, section '17.4.3.1 Clearing Individual Buffers' of the OpenGL 4.5 spec states: "An INVALID_ENUM error is generated by ClearBufferiv and ClearNamedFramebufferiv if buffer is not COLOR or STENCIL." Fixes 1 dEQP test: * dEQP-GLES3.functional.negative_api.buffer.clear_bufferiv Reviewed-by: Ian Romanick --- src/mesa/main/clear.c | 12 1 file changed, 12 insertions(+) diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c index 8284dca..3bfcc5c 100644 --- a/src/mesa/main/clear.c +++ b/src/mesa/main/clear.c @@ -325,6 +325,18 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value) _mesa_update_state( ctx ); } + /* Page 498 of the PDF, section '17.4.3.1 Clearing Individual Buffers' +* of the OpenGL 4.5 spec states: +* +*"An INVALID_ENUM error is generated by ClearBufferiv and +* ClearNamedFramebufferiv if buffer is not COLOR or STENCIL." +*/ + if (buffer == GL_DEPTH || buffer == GL_DEPTH_STENCIL) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glClearBufferiv(buffer=GL_DEPTH || GL_DEPTH_STENCIL)"); + return; + } + switch (buffer) { case GL_STENCIL: /* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says: ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Fix error in target validation of glCompressedTex( ture)SubImage3D() calls
Module: Mesa Branch: master Commit: b469cf10efd4734038dcab294f23ca38e9fc7a97 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b469cf10efd4734038dcab294f23ca38e9fc7a97 Author: Eduardo Lima Mitev Date: Thu Jul 23 16:25:21 2015 +0200 mesa: Fix error in target validation of glCompressedTex(ture)SubImage3D() calls Basically, two different target error checks are chained consecutively, and the second one is executed regardless the result of the first one. This produces an incorrect error if the first check fails but is overrided by the second. This patch conditions the execution of the second check to a successful pass of the first one. Fixes 1 dEQP test: * dEQP-GLES3.functional.negative_api.texture.compressedtexsubimage3d Reviewed-by: Laura Ekstrand --- src/mesa/main/teximage.c |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 3b309ab..cd45113 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -4586,7 +4586,8 @@ compressed_subtexture_target_check(struct gl_context *ctx, GLenum target, * are valid here, which they are not, but of course not mentioned by * core spec. */ - if (target != GL_TEXTURE_2D_ARRAY && target != GL_TEXTURE_CUBE_MAP_ARRAY) { + if (targetOK && target != GL_TEXTURE_2D_ARRAY && + target != GL_TEXTURE_CUBE_MAP_ARRAY) { bool invalidformat; switch (format) { /* These came from _mesa_is_compressed_format in glformats.c. */ ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): nir: prevent use-after-free condition in should_lower_phi()
Module: Mesa Branch: master Commit: 5b226a12420993a0f4aae2295b33aaa305242a3d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5b226a12420993a0f4aae2295b33aaa305242a3d Author: Eduardo Lima Mitev Date: Tue Jun 2 13:42:46 2015 +0200 nir: prevent use-after-free condition in should_lower_phi() lower_phis_to_scalar() pass recurses the instruction dependence graph to determine if all the sources of a given instruction are scalarizable. To prevent cycles, it temporary marks the phi instruction before recursing in, then updates the entry with the resulting value. However, it does not consider that the entry value may have changed after a recursion pass, hence causing a use-after-free situation and a crash. This patch fixes this by reloading the entry corresponding to the 'phi' after recursing and before updating its value. The crash can be reproduced ~20% of times with the dEQP test: dEQP-GLES3.functional.shaders.loops.while_constant_iterations.nested_sequence_fragment Reviewed-by: Jason Ekstrand --- src/glsl/nir/nir_lower_phis_to_scalar.c |5 + 1 file changed, 5 insertions(+) diff --git a/src/glsl/nir/nir_lower_phis_to_scalar.c b/src/glsl/nir/nir_lower_phis_to_scalar.c index 4bdb800..a57d253 100644 --- a/src/glsl/nir/nir_lower_phis_to_scalar.c +++ b/src/glsl/nir/nir_lower_phis_to_scalar.c @@ -153,6 +153,11 @@ should_lower_phi(nir_phi_instr *phi, struct lower_phis_to_scalar_state *state) break; } + /* The hash table entry for 'phi' may have changed while recursing the +* dependence graph, so we need to reset it */ + entry = _mesa_hash_table_search(state->phi_table, phi); + assert(entry); + entry->data = (void *)(intptr_t)scalarizable; return scalarizable; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): glsl: optimize (0 cmp x + y) into (-x cmp y).
Module: Mesa Branch: master Commit: b43bbfa90ace596c8b2e0b3954a5f69924726c59 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b43bbfa90ace596c8b2e0b3954a5f69924726c59 Author: Samuel Iglesias Gonsalvez Date: Tue Feb 24 19:02:57 2015 +0100 glsl: optimize (0 cmp x + y) into (-x cmp y). The optimization done by commit 34ec1a24d did not take it into account. Fixes: dEQP-GLES3.functional.shaders.random.all_features.fragment.20 Signed-off-by: Samuel Iglesias Gonsalvez Reviewed-by: Ian Romanick Reviewed-by: Matt Turner Cc: "10.4 10.5" --- src/glsl/opt_algebraic.cpp | 15 --- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index c6040bf..69c03ea 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -626,9 +626,18 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) if (!is_vec_zero(zero)) continue; - return new(mem_ctx) ir_expression(ir->operation, - add->operands[0], - neg(add->operands[1])); + /* Depending of the zero position we want to optimize + * (0 cmp x+y) into (-x cmp y) or (x+y cmp 0) into (x cmp -y) + */ + if (add_pos == 1) { +return new(mem_ctx) ir_expression(ir->operation, + neg(add->operands[0]), + add->operands[1]); + } else { +return new(mem_ctx) ir_expression(ir->operation, + add->operands[0], + neg(add->operands[1])); + } } break; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): meta: Remove error checks for texture <-> pixel-buffer transfers that don't belong in driver code
Module: Mesa Branch: master Commit: f6f7bfb5e1308593df9642aa8f46a17e8ce340a2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f6f7bfb5e1308593df9642aa8f46a17e8ce340a2 Author: Eduardo Lima Mitev Date: Tue Mar 10 19:33:30 2015 +0100 meta: Remove error checks for texture <-> pixel-buffer transfers that don't belong in driver code The implementation of texture <-> pixel-buffer transfers in drivers common layer includes certain error checks and argument validation that don't belong there, considering how the Mesa codebase is laid out. These are higher level validations that, if necessary, should be performed earlier (i.e, in GL API entry points). This patch simply removes these error checks from driver code. For more information, see discussion at http://lists.freedesktop.org/archives/mesa-dev/2015-February/077417.html. Reviewed-by: Laura Ekstrand --- src/mesa/drivers/common/meta_tex_subimage.c | 32 --- 1 file changed, 32 deletions(-) diff --git a/src/mesa/drivers/common/meta_tex_subimage.c b/src/mesa/drivers/common/meta_tex_subimage.c index e29addb..ad6e787 100644 --- a/src/mesa/drivers/common/meta_tex_subimage.c +++ b/src/mesa/drivers/common/meta_tex_subimage.c @@ -150,9 +150,6 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, bool success = false; int z; - /* XXX: This should probably be passed in from somewhere */ - const char *where = "_mesa_meta_pbo_TexSubImage"; - if (!_mesa_is_bufferobj(packing->BufferObj) && !create_pbo) return false; @@ -165,19 +162,6 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, if (ctx->_ImageTransferState) return false; - if (!_mesa_validate_pbo_access(dims, packing, width, height, depth, - format, type, INT_MAX, pixels)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(out of bounds PBO access)", where); - return true; - } - - if (_mesa_check_disallowed_mapping(packing->BufferObj)) { - /* buffer is mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(PBO is mapped)", where); - return true; - } - /* For arrays, use a tall (height * depth) 2D texture but taking into * account the inter-image padding specified with the image height packing * property. @@ -277,9 +261,6 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, bool success = false; int z; - /* XXX: This should probably be passed in from somewhere */ - const char *where = "_mesa_meta_pbo_GetTexSubImage"; - if (!_mesa_is_bufferobj(packing->BufferObj)) return false; @@ -292,19 +273,6 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, if (ctx->_ImageTransferState) return false; - if (!_mesa_validate_pbo_access(dims, packing, width, height, depth, - format, type, INT_MAX, pixels)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(out of bounds PBO access)", where); - return true; - } - - if (_mesa_check_disallowed_mapping(packing->BufferObj)) { - /* buffer is mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(PBO is mapped)", where); - return true; - } - /* For arrays, use a tall (height * depth) 2D texture but taking into * account the inter-image padding specified with the image height packing * property. ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Separate PBO validation checks from buffer mapping, to allow reuse
Module: Mesa Branch: master Commit: 7c084752c612c1763212830618ee0a86f4edf8f6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7c084752c612c1763212830618ee0a86f4edf8f6 Author: Eduardo Lima Mitev Date: Thu Mar 12 08:14:03 2015 +0100 mesa: Separate PBO validation checks from buffer mapping, to allow reuse Internal PBO functions such as _mesa_map_validate_pbo_source() and _mesa_validate_pbo_compressed_teximage() perform validation and buffer mapping within the same call. This patch takes out the validation into separate functions to allow reuse of functionality by other code (i.e, gl(Compressed)Tex(Sub)Image). Reviewed-by: Laura Ekstrand --- src/mesa/main/pbo.c | 117 +-- src/mesa/main/pbo.h | 14 ++ 2 files changed, 100 insertions(+), 31 deletions(-) diff --git a/src/mesa/main/pbo.c b/src/mesa/main/pbo.c index 259f763..0c16025 100644 --- a/src/mesa/main/pbo.c +++ b/src/mesa/main/pbo.c @@ -164,23 +164,18 @@ _mesa_map_pbo_source(struct gl_context *ctx, return buf; } - /** - * Combine PBO-read validation and mapping. - * If any GL errors are detected, they'll be recorded and NULL returned. + * Perform PBO validation for read operations with uncompressed textures. + * If any GL errors are detected, false is returned, otherwise returns true. * \sa _mesa_validate_pbo_access - * \sa _mesa_map_pbo_source - * A call to this function should have a matching call to - * _mesa_unmap_pbo_source(). */ -const GLvoid * -_mesa_map_validate_pbo_source(struct gl_context *ctx, - GLuint dimensions, - const struct gl_pixelstore_attrib *unpack, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, - GLsizei clientMemSize, - const GLvoid *ptr, const char *where) +bool +_mesa_validate_pbo_source(struct gl_context *ctx, GLuint dimensions, + const struct gl_pixelstore_attrib *unpack, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, + GLsizei clientMemSize, + const GLvoid *ptr, const char *where) { assert(dimensions == 1 || dimensions == 2 || dimensions == 3); @@ -188,24 +183,85 @@ _mesa_map_validate_pbo_source(struct gl_context *ctx, format, type, clientMemSize, ptr)) { if (_mesa_is_bufferobj(unpack->BufferObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "%s(out of bounds PBO access)", where); + "%s(out of bounds PBO access)", + where); } else { _mesa_error(ctx, GL_INVALID_OPERATION, "%s(out of bounds access: bufSize (%d) is too small)", where, clientMemSize); } - return NULL; + return false; } if (!_mesa_is_bufferobj(unpack->BufferObj)) { /* non-PBO access: no further validation to be done */ - return ptr; + return true; } if (_mesa_check_disallowed_mapping(unpack->BufferObj)) { /* buffer is already mapped - that's an error */ - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(PBO is mapped)", where); - return NULL; + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(PBO is mapped)", + where); + return false; + } + + return true; +} + +/** + * Perform PBO validation for read operations with compressed textures. + * If any GL errors are detected, false is returned, otherwise returns true. + */ +bool +_mesa_validate_pbo_source_compressed(struct gl_context *ctx, GLuint dimensions, + const struct gl_pixelstore_attrib *unpack, + GLsizei imageSize, const GLvoid *pixels, + const char *where) +{ + if (!_mesa_is_bufferobj(unpack->BufferObj)) { + /* not using a PBO */ + return true; + } + + if ((const GLubyte *) pixels + imageSize > + ((const GLubyte *) 0) + unpack->BufferObj->Size) { + /* out of bounds read! */ + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid PBO access)", + where); + return false; + } + + if (_mesa_check_disallowed_mapping(unpack->BufferObj)) { + /* buffer is already mapped - that's an error */ + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(PBO is mapped)", + where); + return false; + } + + return true; +} + +/** + * Perform PBO-read mapping. + * If any GL errors are detected, they'll be recorded and NULL returned. + * \sa _mesa_validate_pbo_source + * \sa _mesa_map_pbo_source + * A call to this function shoul
Mesa (master): mesa: Set the correct image size in _mesa_validate_pbo_access()
Module: Mesa Branch: master Commit: 7b5bb97cefbf1d0cfef28bc974ee9a68024e3b45 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7b5bb97cefbf1d0cfef28bc974ee9a68024e3b45 Author: Eduardo Lima Mitev Date: Thu Mar 5 09:20:11 2015 +0100 mesa: Set the correct image size in _mesa_validate_pbo_access() _mesa_validate_pbo_access() provides a generic way to check that a requested pixel transfer operation on a PBO falls within the boundaries of the buffer. It is used in various other places, and depending on the caller, some arguments are used or not. In particular, the 'clientMemSize' argument is used only by calls that are knowledgeable of the total size of the user data involved in a pixel transfer, such as the case of compressed texture image calls. Other calls don't provide 'clientMemSize' directly since it is made implicit from the size and format of the texture, and its data type. In these cases, a sufficiently big value is passed to 'clientMemSize' (INT_MAX) to avoid an incorrect constrain. The problem is that _mesa_validate_pbo_access() use uint pointers to make the calculations, which are 64 bits long in 64 bits platforms, meanwhile the dummy INT_MAX passed in 'clientMemSize' is just 32 bits. This causes a constrain that is not desired. This patch fixes that by checking that if 'clientMemSize' is MAX_INT, then UINTPTR_MAX is assumed instead. This is an ugly workaround to the fact that _mesa_validate_pbo_access() intends to be a one function fits all. The clean solution here would be to break it into different functions that provide the adequate API for each of the possible code paths and validation needs. Since there are callers relying on passing INT_MAX to 'clientMemSize', this patch is necessary to deal with the problem above while a cleaner implementation of the PBO API is not implemented. Reviewed-by: Laura Ekstrand --- src/mesa/main/pbo.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/pbo.c b/src/mesa/main/pbo.c index 5c906ed..259f763 100644 --- a/src/mesa/main/pbo.c +++ b/src/mesa/main/pbo.c @@ -80,7 +80,7 @@ _mesa_validate_pbo_access(GLuint dimensions, */ if (!_mesa_is_bufferobj(pack->BufferObj)) { offset = 0; - size = clientMemSize; + size = (clientMemSize == INT_MAX) ? UINTPTR_MAX : clientMemSize; } else { offset = (uintptr_t)ptr; size = pack->BufferObj->Size; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Check for valid PBO access in gl(Compressed)Tex(Sub) Image calls
Module: Mesa Branch: master Commit: cf6f33ee68ca56df1650762634fa9c038359c3ec URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cf6f33ee68ca56df1650762634fa9c038359c3ec Author: Eduardo Lima Mitev Date: Thu Mar 12 08:16:09 2015 +0100 mesa: Check for valid PBO access in gl(Compressed)Tex(Sub)Image calls This patch adds two types of checks to the gl(Compressed)Tex(Sub)Imgage family of functions when a pixel buffer object is bound to GL_PIXEL_UNPACK_BUFFER: - That the buffer is not mapped. - The total data size is within the boundaries of the buffer size. It does so by calling auxiliary validations functions from PBO API: _mesa_validate_pbo_source() for non-compressed texture calls, and _mesa_validate_pbo_source_compressed() for compressed texture calls. The first check is defined in Section 6.3.2 'Effects of Mapping Buffers on Other GL Commands' of the GLES 3.1 spec, page 57: "Any GL command which attempts to read from, write to, or change the state of a buffer object may generate an INVALID_OPERATION error if all or part of the buffer object is mapped. However, only commands which explicitly describe this error are required to do so. If an error is not generated, using such commands to perform invalid reads, writes, or state changes will have undefined results and may result in GL interruption or termination." Similar wording exists in GL 4.5 spec, page 76. In the case of gl(Compressed)Tex(Sub)Image(2,3)D, the specification doesn't force implemtations to throw an error. However since Mesa don't currently implement checks to determine when it is safe to read/write from/to a mapped PBO, we should always return the error if all or parts of it are mapped. The 2nd check is defined in Section 8.5 'Texture Image Specification' of the OpenGL 4.5 spec, page 203: "An INVALID_OPERATION error is generated if a pixel unpack buffer object is bound and storing texture data would access memory beyond the end of the pixel unpack buffer." Fixes 4 dEQP tests: * dEQP-GLES3.functional.negative_api.texture.compressedteximage2d_invalid_buffer_target * dEQP-GLES3.functional.negative_api.texture.compressedtexsubimage2d_invalid_buffer_target * dEQP-GLES3.functional.negative_api.texture.compressedteximage3d_invalid_buffer_target * dEQP-GLES3.functional.negative_api.texture.compressedtexsubimage3d_invalid_buffer_target Reviewed-by: Laura Ekstrand --- src/mesa/main/teximage.c | 180 ++ 1 file changed, 103 insertions(+), 77 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 7b1a0e6..64e4816 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -53,6 +53,7 @@ #include "mtypes.h" #include "glformats.h" #include "texstore.h" +#include "pbo.h" /** @@ -1619,32 +1620,30 @@ error_check_subtexture_dimensions(struct gl_context *ctx, GLuint dims, /* Check size */ if (subWidth < 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "%s%dD(width=%d)", func, dims, subWidth); + "%s(width=%d)", func, subWidth); return GL_TRUE; } if (dims > 1 && subHeight < 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "%s%dD(height=%d)", func, dims, subHeight); + "%s(height=%d)", func, subHeight); return GL_TRUE; } if (dims > 2 && subDepth < 0) { _mesa_error(ctx, GL_INVALID_VALUE, - "%s%dD(depth=%d)", func, dims, subDepth); + "%s(depth=%d)", func, subDepth); return GL_TRUE; } /* check xoffset and width */ if (xoffset < - (GLint) destImage->Border) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s%dD(xoffset)", - func, dims); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(xoffset)", func); return GL_TRUE; } if (xoffset + subWidth > (GLint) destImage->Width) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s%dD(xoffset+width)", - func, dims); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(xoffset+width)", func); return GL_TRUE; } @@ -1652,13 +1651,11 @@ error_check_subtexture_dimensions(struct gl_context *ctx, GLuint dims, if (dims > 1) { GLint yBorder = (target == GL_TEXTURE_1D_ARRAY) ? 0 : destImage->Border; if (yoffset < -yBorder) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s%dD(yoffset)", - func, dims); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(yoffset)", func); return GL_TRUE; } if (yoffset + subHeight > (GLint) destImage->Height) { - _mesa_error(ctx, GL_INVALID_VALUE, "%s%dD(yoffset+height)", -