diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2015-12-23 13:23:27 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2015-12-23 13:23:27 +0000 |
commit | 2f35ab22e92c7e0d9211cd62d9e57904c69940a0 (patch) | |
tree | 12557676961b424bdb47ec97baf072a809dd5828 /lib/mesa/src | |
parent | 6aafc20001973c4e22a7d3e8ab33bb5bd3d69982 (diff) |
Import Mesa 11.0.8
This seems to fix some of the problems with clutter/gnome reported to
occur on r600 with 11.0.6
Diffstat (limited to 'lib/mesa/src')
27 files changed, 544 insertions, 334 deletions
diff --git a/lib/mesa/src/egl/drivers/dri2/platform_wayland.c b/lib/mesa/src/egl/drivers/dri2/platform_wayland.c index dbc64ba2d..27fa93522 100644 --- a/lib/mesa/src/egl/drivers/dri2/platform_wayland.c +++ b/lib/mesa/src/egl/drivers/dri2/platform_wayland.c @@ -703,18 +703,10 @@ dri2_wl_swap_buffers_with_damage(_EGLDriver *drv, dri2_surf->dx = 0; dri2_surf->dy = 0; - if (n_rects == 0) { - wl_surface_damage(dri2_surf->wl_win->surface, - 0, 0, INT32_MAX, INT32_MAX); - } else { - for (i = 0; i < n_rects; i++) { - const int *rect = &rects[i * 4]; - wl_surface_damage(dri2_surf->wl_win->surface, - rect[0], - dri2_surf->base.Height - rect[1] - rect[3], - rect[2], rect[3]); - } - } + /* We deliberately ignore the damage region and post maximum damage, due to + * https://bugs.freedesktop.org/78190 */ + wl_surface_damage(dri2_surf->wl_win->surface, + 0, 0, INT32_MAX, INT32_MAX); if (dri2_dpy->is_different_gpu) { _EGLContext *ctx = _eglGetCurrentContext(); diff --git a/lib/mesa/src/glsl/ast_to_hir.cpp b/lib/mesa/src/glsl/ast_to_hir.cpp index 94bae579b..e560852c6 100644 --- a/lib/mesa/src/glsl/ast_to_hir.cpp +++ b/lib/mesa/src/glsl/ast_to_hir.cpp @@ -2281,7 +2281,9 @@ validate_binding_qualifier(struct _mesa_glsl_parse_state *state, return false; } - } else if (state->is_version(420, 310) && base_type->is_image()) { + } else if ((state->is_version(420, 310) || + state->ARB_shading_language_420pack_enable) && + base_type->is_image()) { assert(ctx->Const.MaxImageUnits <= MAX_IMAGE_UNITS); if (max_index >= ctx->Const.MaxImageUnits) { _mesa_glsl_error(loc, state, "Image binding %d exceeds the " diff --git a/lib/mesa/src/glsl/ir.cpp b/lib/mesa/src/glsl/ir.cpp index 724861b1e..f092bc4f6 100644 --- a/lib/mesa/src/glsl/ir.cpp +++ b/lib/mesa/src/glsl/ir.cpp @@ -1402,8 +1402,7 @@ static const char * const tex_opcode_strs[] = { "tex", "txb", "txl", "txd", "txf const char *ir_texture::opcode_string() { - assert((unsigned int) op <= - sizeof(tex_opcode_strs) / sizeof(tex_opcode_strs[0])); + assert((unsigned int) op < ARRAY_SIZE(tex_opcode_strs)); return tex_opcode_strs[op]; } diff --git a/lib/mesa/src/glsl/linker.cpp b/lib/mesa/src/glsl/linker.cpp index 934062f24..8ea7bd48e 100644 --- a/lib/mesa/src/glsl/linker.cpp +++ b/lib/mesa/src/glsl/linker.cpp @@ -3754,13 +3754,13 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) if (first < MESA_SHADER_FRAGMENT) { gl_shader *const sh = prog->_LinkedShaders[last]; - if (first == MESA_SHADER_GEOMETRY) { + if (first != MESA_SHADER_VERTEX) { /* There was no vertex shader, but we still have to assign varying - * locations for use by geometry shader inputs in SSO. + * locations for use by tessellation/geometry shader inputs in SSO. * * If the shader is not separable (i.e., prog->SeparateShader is - * false), linking will have already failed when first is - * MESA_SHADER_GEOMETRY. + * false), linking will have already failed when first is not + * MESA_SHADER_VERTEX. */ if (!assign_varying_locations(ctx, mem_ctx, prog, NULL, prog->_LinkedShaders[first], diff --git a/lib/mesa/src/glsl/nir/nir_lower_idiv.c b/lib/mesa/src/glsl/nir/nir_lower_idiv.c index 7b6803207..7654593a1 100644 --- a/lib/mesa/src/glsl/nir/nir_lower_idiv.c +++ b/lib/mesa/src/glsl/nir/nir_lower_idiv.c @@ -96,7 +96,7 @@ convert_instr(nir_builder *bld, nir_alu_instr *alu) r = nir_imul(bld, q, b); r = nir_isub(bld, a, r); - r = nir_ige(bld, r, b); + r = nir_uge(bld, r, b); r = nir_b2i(bld, r); q = nir_iadd(bld, q, r); diff --git a/lib/mesa/src/mesa/drivers/common/meta.c b/lib/mesa/src/mesa/drivers/common/meta.c index bde544ef4..1e5732317 100644 --- a/lib/mesa/src/mesa/drivers/common/meta.c +++ b/lib/mesa/src/mesa/drivers/common/meta.c @@ -95,9 +95,12 @@ static struct blit_shader * choose_blit_shader(GLenum target, struct blit_shader_table *table); static void cleanup_temp_texture(struct temp_texture *tex); -static void meta_glsl_clear_cleanup(struct clear_state *clear); -static void meta_decompress_cleanup(struct decompress_state *decompress); -static void meta_drawpix_cleanup(struct drawpix_state *drawpix); +static void meta_glsl_clear_cleanup(struct gl_context *ctx, + struct clear_state *clear); +static void meta_decompress_cleanup(struct gl_context *ctx, + struct decompress_state *decompress); +static void meta_drawpix_cleanup(struct gl_context *ctx, + struct drawpix_state *drawpix); void _mesa_meta_bind_fbo_image(GLenum fboTarget, GLenum attachment, @@ -310,13 +313,13 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx, /** * Configure vertex buffer and vertex array objects for tests * - * Regardless of whether a new VAO and new VBO are created, the objects - * referenced by \c VAO and \c VBO will be bound into the GL state vector - * when this function terminates. + * Regardless of whether a new VAO is created, the object referenced by \c VAO + * will be bound into the GL state vector when this function terminates. The + * object referenced by \c VBO will \b not be bound. * * \param VAO Storage for vertex array object handle. If 0, a new VAO * will be created. - * \param VBO Storage for vertex buffer object handle. If 0, a new VBO + * \param buf_obj Storage for vertex buffer object pointer. If \c NULL, a new VBO * will be created. The new VBO will have storage for 4 * \c vertex structures. * \param use_generic_attributes Should generic attributes 0 and 1 be used, @@ -333,57 +336,84 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx, * Use \c texcoord_size instead. */ void -_mesa_meta_setup_vertex_objects(GLuint *VAO, GLuint *VBO, +_mesa_meta_setup_vertex_objects(struct gl_context *ctx, + GLuint *VAO, struct gl_buffer_object **buf_obj, bool use_generic_attributes, unsigned vertex_size, unsigned texcoord_size, unsigned color_size) { if (*VAO == 0) { - assert(*VBO == 0); + struct gl_vertex_array_object *array_obj; + assert(*buf_obj == NULL); /* create vertex array object */ _mesa_GenVertexArrays(1, VAO); _mesa_BindVertexArray(*VAO); + array_obj = _mesa_lookup_vao(ctx, *VAO); + assert(array_obj != NULL); + /* create vertex array buffer */ - _mesa_GenBuffers(1, VBO); - _mesa_BindBuffer(GL_ARRAY_BUFFER, *VBO); - _mesa_BufferData(GL_ARRAY_BUFFER, 4 * sizeof(struct vertex), NULL, - GL_DYNAMIC_DRAW); + *buf_obj = ctx->Driver.NewBufferObject(ctx, 0xDEADBEEF); + if (*buf_obj == NULL) + return; + + _mesa_buffer_data(ctx, *buf_obj, GL_NONE, 4 * sizeof(struct vertex), NULL, + GL_DYNAMIC_DRAW, __func__); /* setup vertex arrays */ if (use_generic_attributes) { assert(color_size == 0); - _mesa_VertexAttribPointer(0, vertex_size, GL_FLOAT, GL_FALSE, - sizeof(struct vertex), OFFSET(x)); - _mesa_EnableVertexAttribArray(0); - + _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_GENERIC(0), + vertex_size, GL_FLOAT, GL_RGBA, GL_FALSE, + GL_FALSE, GL_FALSE, + offsetof(struct vertex, x), true); + _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_GENERIC(0), + *buf_obj, 0, sizeof(struct vertex)); + _mesa_enable_vertex_array_attrib(ctx, array_obj, + VERT_ATTRIB_GENERIC(0)); if (texcoord_size > 0) { - _mesa_VertexAttribPointer(1, texcoord_size, GL_FLOAT, GL_FALSE, - sizeof(struct vertex), OFFSET(tex)); - _mesa_EnableVertexAttribArray(1); + _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_GENERIC(1), + texcoord_size, GL_FLOAT, GL_RGBA, + GL_FALSE, GL_FALSE, GL_FALSE, + offsetof(struct vertex, tex), false); + _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_GENERIC(1), + *buf_obj, 0, sizeof(struct vertex)); + _mesa_enable_vertex_array_attrib(ctx, array_obj, + VERT_ATTRIB_GENERIC(1)); } } else { - _mesa_VertexPointer(vertex_size, GL_FLOAT, sizeof(struct vertex), - OFFSET(x)); - _mesa_EnableClientState(GL_VERTEX_ARRAY); + _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_POS, + vertex_size, GL_FLOAT, GL_RGBA, GL_FALSE, + GL_FALSE, GL_FALSE, + offsetof(struct vertex, x), true); + _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_POS, + *buf_obj, 0, sizeof(struct vertex)); + _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_POS); if (texcoord_size > 0) { - _mesa_TexCoordPointer(texcoord_size, GL_FLOAT, - sizeof(struct vertex), OFFSET(tex)); - _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY); + _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_TEX(0), + vertex_size, GL_FLOAT, GL_RGBA, GL_FALSE, + GL_FALSE, GL_FALSE, + offsetof(struct vertex, tex), false); + _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_TEX(0), + *buf_obj, 0, sizeof(struct vertex)); + _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_TEX(0)); } if (color_size > 0) { - _mesa_ColorPointer(color_size, GL_FLOAT, - sizeof(struct vertex), OFFSET(r)); - _mesa_EnableClientState(GL_COLOR_ARRAY); + _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_COLOR0, + vertex_size, GL_FLOAT, GL_RGBA, GL_FALSE, + GL_FALSE, GL_FALSE, + offsetof(struct vertex, r), false); + _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_COLOR0, + *buf_obj, 0, sizeof(struct vertex)); + _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_COLOR0); } } } else { _mesa_BindVertexArray(*VAO); - _mesa_BindBuffer(GL_ARRAY_BUFFER, *VBO); } } @@ -408,12 +438,12 @@ _mesa_meta_free(struct gl_context *ctx) { GET_CURRENT_CONTEXT(old_context); _mesa_make_current(ctx, NULL, NULL); - _mesa_meta_glsl_blit_cleanup(&ctx->Meta->Blit); - meta_glsl_clear_cleanup(&ctx->Meta->Clear); - _mesa_meta_glsl_generate_mipmap_cleanup(&ctx->Meta->Mipmap); + _mesa_meta_glsl_blit_cleanup(ctx, &ctx->Meta->Blit); + meta_glsl_clear_cleanup(ctx, &ctx->Meta->Clear); + _mesa_meta_glsl_generate_mipmap_cleanup(ctx, &ctx->Meta->Mipmap); cleanup_temp_texture(&ctx->Meta->TempTex); - meta_decompress_cleanup(&ctx->Meta->Decompress); - meta_drawpix_cleanup(&ctx->Meta->DrawPix); + meta_decompress_cleanup(ctx, &ctx->Meta->Decompress); + meta_drawpix_cleanup(ctx, &ctx->Meta->DrawPix); if (old_context) _mesa_make_current(old_context, old_context->WinSysDrawBuffer, old_context->WinSysReadBuffer); else @@ -1477,10 +1507,12 @@ _mesa_meta_setup_drawpix_texture(struct gl_context *ctx, } void -_mesa_meta_setup_ff_tnl_for_blit(GLuint *VAO, GLuint *VBO, +_mesa_meta_setup_ff_tnl_for_blit(struct gl_context *ctx, + GLuint *VAO, struct gl_buffer_object **buf_obj, unsigned texcoord_size) { - _mesa_meta_setup_vertex_objects(VAO, VBO, false, 2, texcoord_size, 0); + _mesa_meta_setup_vertex_objects(ctx, VAO, buf_obj, false, 2, texcoord_size, + 0); /* setup projection matrix */ _mesa_MatrixMode(GL_PROJECTION); @@ -1525,7 +1557,8 @@ meta_glsl_clear_init(struct gl_context *ctx, struct clear_state *clear) GLuint vs, fs; bool has_integer_textures; - _mesa_meta_setup_vertex_objects(&clear->VAO, &clear->VBO, true, 3, 0, 0); + _mesa_meta_setup_vertex_objects(ctx, &clear->VAO, &clear->buf_obj, true, + 3, 0, 0); if (clear->ShaderProg != 0) return; @@ -1606,14 +1639,13 @@ meta_glsl_clear_init(struct gl_context *ctx, struct clear_state *clear) } static void -meta_glsl_clear_cleanup(struct clear_state *clear) +meta_glsl_clear_cleanup(struct gl_context *ctx, struct clear_state *clear) { if (clear->VAO == 0) return; _mesa_DeleteVertexArrays(1, &clear->VAO); clear->VAO = 0; - _mesa_DeleteBuffers(1, &clear->VBO); - clear->VBO = 0; + _mesa_reference_buffer_object(ctx, &clear->buf_obj, NULL); _mesa_DeleteProgram(clear->ShaderProg); clear->ShaderProg = 0; @@ -1721,7 +1753,8 @@ meta_clear(struct gl_context *ctx, GLbitfield buffers, bool glsl) y1 = ((float) fb->_Ymax / fb->Height) * 2.0f - 1.0f; z = -invert_z(ctx->Depth.Clear); } else { - _mesa_meta_setup_vertex_objects(&clear->VAO, &clear->VBO, false, 3, 0, 4); + _mesa_meta_setup_vertex_objects(ctx, &clear->VAO, &clear->buf_obj, false, + 3, 0, 4); x0 = (float) fb->_Xmin; y0 = (float) fb->_Ymin; @@ -1804,8 +1837,8 @@ meta_clear(struct gl_context *ctx, GLbitfield buffers, bool glsl) } /* upload new vertex data */ - _mesa_BufferData(GL_ARRAY_BUFFER_ARB, sizeof(verts), verts, - GL_DYNAMIC_DRAW_ARB); + _mesa_buffer_data(ctx, clear->buf_obj, GL_NONE, sizeof(verts), verts, + GL_DYNAMIC_DRAW, __func__); /* draw quad(s) */ if (fb->MaxNumLayers > 0) { @@ -1851,7 +1884,7 @@ _mesa_meta_CopyPixels(struct gl_context *ctx, GLint srcX, GLint srcY, MESA_META_VERTEX | MESA_META_VIEWPORT)); - _mesa_meta_setup_vertex_objects(©pix->VAO, ©pix->VBO, false, + _mesa_meta_setup_vertex_objects(ctx, ©pix->VAO, ©pix->buf_obj, false, 3, 2, 0); /* Silence valgrind warnings about reading uninitialized stack. */ @@ -1891,7 +1924,8 @@ _mesa_meta_CopyPixels(struct gl_context *ctx, GLint srcX, GLint srcY, verts[3].tex[1] = tex->Ttop; /* upload new vertex data */ - _mesa_BufferSubData(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts); + _mesa_buffer_sub_data(ctx, copypix->buf_obj, 0, sizeof(verts), verts, + __func__); } _mesa_set_enable(ctx, tex->Target, GL_TRUE); @@ -1905,14 +1939,13 @@ _mesa_meta_CopyPixels(struct gl_context *ctx, GLint srcX, GLint srcY, } static void -meta_drawpix_cleanup(struct drawpix_state *drawpix) +meta_drawpix_cleanup(struct gl_context *ctx, struct drawpix_state *drawpix) { if (drawpix->VAO != 0) { _mesa_DeleteVertexArrays(1, &drawpix->VAO); drawpix->VAO = 0; - _mesa_DeleteBuffers(1, &drawpix->VBO); - drawpix->VBO = 0; + _mesa_reference_buffer_object(ctx, &drawpix->buf_obj, NULL); } if (drawpix->StencilFP != 0) { @@ -2172,7 +2205,7 @@ _mesa_meta_DrawPixels(struct gl_context *ctx, newTex = _mesa_meta_alloc_texture(tex, width, height, texIntFormat); - _mesa_meta_setup_vertex_objects(&drawpix->VAO, &drawpix->VBO, false, + _mesa_meta_setup_vertex_objects(ctx, &drawpix->VAO, &drawpix->buf_obj, false, 3, 2, 0); /* Silence valgrind warnings about reading uninitialized stack. */ @@ -2209,8 +2242,8 @@ _mesa_meta_DrawPixels(struct gl_context *ctx, } /* upload new vertex data */ - _mesa_BufferData(GL_ARRAY_BUFFER_ARB, sizeof(verts), - verts, GL_DYNAMIC_DRAW_ARB); + _mesa_buffer_data(ctx, drawpix->buf_obj, GL_NONE, sizeof(verts), verts, + GL_DYNAMIC_DRAW, __func__); /* set given unpack params */ ctx->Unpack = *unpack; @@ -2365,7 +2398,8 @@ _mesa_meta_Bitmap(struct gl_context *ctx, MESA_META_VERTEX | MESA_META_VIEWPORT)); - _mesa_meta_setup_vertex_objects(&bitmap->VAO, &bitmap->VBO, false, 3, 2, 4); + _mesa_meta_setup_vertex_objects(ctx, &bitmap->VAO, &bitmap->buf_obj, false, + 3, 2, 4); newTex = _mesa_meta_alloc_texture(tex, width, height, texIntFormat); @@ -2410,7 +2444,8 @@ _mesa_meta_Bitmap(struct gl_context *ctx, } /* upload new vertex data */ - _mesa_BufferSubData(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts); + _mesa_buffer_sub_data(ctx, bitmap->buf_obj, 0, sizeof(verts), verts, + __func__); } /* choose different foreground/background alpha values */ @@ -2939,14 +2974,15 @@ meta_decompress_fbo_cleanup(struct decompress_fbo_state *decompress_fbo) } static void -meta_decompress_cleanup(struct decompress_state *decompress) +meta_decompress_cleanup(struct gl_context *ctx, + struct decompress_state *decompress) { meta_decompress_fbo_cleanup(&decompress->byteFBO); meta_decompress_fbo_cleanup(&decompress->floatFBO); if (decompress->VAO != 0) { _mesa_DeleteVertexArrays(1, &decompress->VAO); - _mesa_DeleteBuffers(1, &decompress->VBO); + _mesa_reference_buffer_object(ctx, &decompress->buf_obj, NULL); } if (decompress->Sampler != 0) @@ -3066,12 +3102,14 @@ decompress_texture_image(struct gl_context *ctx, } if (use_glsl_version) { - _mesa_meta_setup_vertex_objects(&decompress->VAO, &decompress->VBO, true, + _mesa_meta_setup_vertex_objects(ctx, &decompress->VAO, + &decompress->buf_obj, true, 2, 4, 0); _mesa_meta_setup_blit_shader(ctx, target, false, &decompress->shaders); } else { - _mesa_meta_setup_ff_tnl_for_blit(&decompress->VAO, &decompress->VBO, 3); + _mesa_meta_setup_ff_tnl_for_blit(ctx, &decompress->VAO, + &decompress->buf_obj, 3); } if (!decompress->Sampler) { @@ -3115,7 +3153,8 @@ decompress_texture_image(struct gl_context *ctx, _mesa_set_viewport(ctx, 0, 0, 0, width, height); /* upload new vertex data */ - _mesa_BufferSubData(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts); + _mesa_buffer_sub_data(ctx, decompress->buf_obj, 0, sizeof(verts), verts, + __func__); /* setup texture state */ _mesa_BindTexture(target, texObj->Name); @@ -3259,36 +3298,45 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z, if (drawtex->VAO == 0) { /* one-time setup */ - GLint active_texture; + struct gl_vertex_array_object *array_obj; /* create vertex array object */ _mesa_GenVertexArrays(1, &drawtex->VAO); _mesa_BindVertexArray(drawtex->VAO); + array_obj = _mesa_lookup_vao(ctx, drawtex->VAO); + assert(array_obj != NULL); + /* create vertex array buffer */ - _mesa_GenBuffers(1, &drawtex->VBO); - _mesa_BindBuffer(GL_ARRAY_BUFFER_ARB, drawtex->VBO); - _mesa_BufferData(GL_ARRAY_BUFFER_ARB, sizeof(verts), - NULL, GL_DYNAMIC_DRAW_ARB); + drawtex->buf_obj = ctx->Driver.NewBufferObject(ctx, 0xDEADBEEF); + if (drawtex->buf_obj == NULL) + return; - /* client active texture is not part of the array object */ - active_texture = ctx->Array.ActiveTexture; + _mesa_buffer_data(ctx, drawtex->buf_obj, GL_NONE, sizeof(verts), verts, + GL_DYNAMIC_DRAW, __func__); /* setup vertex arrays */ - _mesa_VertexPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(x)); - _mesa_EnableClientState(GL_VERTEX_ARRAY); + _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_POS, + 3, GL_FLOAT, GL_RGBA, GL_FALSE, + GL_FALSE, GL_FALSE, + offsetof(struct vertex, x), true); + _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_POS, + drawtex->buf_obj, 0, sizeof(struct vertex)); + _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_POS); + + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { - _mesa_ClientActiveTexture(GL_TEXTURE0 + i); - _mesa_TexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), OFFSET(st[i])); - _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY); + _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_TEX(i), + 2, GL_FLOAT, GL_RGBA, GL_FALSE, + GL_FALSE, GL_FALSE, + offsetof(struct vertex, st[i]), true); + _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_TEX(i), + drawtex->buf_obj, 0, sizeof(struct vertex)); + _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_TEX(i)); } - - /* restore client active texture */ - _mesa_ClientActiveTexture(GL_TEXTURE0 + active_texture); } else { _mesa_BindVertexArray(drawtex->VAO); - _mesa_BindBuffer(GL_ARRAY_BUFFER_ARB, drawtex->VBO); } /* vertex positions, texcoords */ @@ -3353,7 +3401,8 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z, verts[3].st[i][1] = t1; } - _mesa_BufferSubData(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts); + _mesa_buffer_sub_data(ctx, drawtex->buf_obj, 0, sizeof(verts), verts, + __func__); } _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); diff --git a/lib/mesa/src/mesa/drivers/common/meta.h b/lib/mesa/src/mesa/drivers/common/meta.h index fe439153a..c32e7bd9b 100644 --- a/lib/mesa/src/mesa/drivers/common/meta.h +++ b/lib/mesa/src/mesa/drivers/common/meta.h @@ -297,7 +297,7 @@ enum blit_msaa_shader { struct blit_state { GLuint VAO; - GLuint VBO; + struct gl_buffer_object *buf_obj; struct blit_shader_table shaders_with_depth; struct blit_shader_table shaders_without_depth; GLuint msaa_shaders[BLIT_MSAA_SHADER_COUNT]; @@ -319,7 +319,7 @@ struct fb_tex_blit_state struct clear_state { GLuint VAO; - GLuint VBO; + struct gl_buffer_object *buf_obj; GLuint ShaderProg; GLint ColorLocation; GLint LayerLocation; @@ -336,7 +336,7 @@ struct clear_state struct copypix_state { GLuint VAO; - GLuint VBO; + struct gl_buffer_object *buf_obj; }; @@ -346,7 +346,7 @@ struct copypix_state struct drawpix_state { GLuint VAO; - GLuint VBO; + struct gl_buffer_object *buf_obj; GLuint StencilFP; /**< Fragment program for drawing stencil images */ GLuint DepthFP; /**< Fragment program for drawing depth images */ @@ -359,7 +359,7 @@ struct drawpix_state struct bitmap_state { GLuint VAO; - GLuint VBO; + struct gl_buffer_object *buf_obj; struct temp_texture Tex; /**< separate texture from other meta ops */ }; @@ -369,7 +369,7 @@ struct bitmap_state struct gen_mipmap_state { GLuint VAO; - GLuint VBO; + struct gl_buffer_object *buf_obj; GLuint FBO; GLuint Sampler; @@ -393,7 +393,8 @@ struct decompress_state { GLuint VAO; struct decompress_fbo_state byteFBO, floatFBO; - GLuint VBO, Sampler; + struct gl_buffer_object *buf_obj; + GLuint Sampler; struct blit_shader_table shaders; }; @@ -404,7 +405,7 @@ struct decompress_state struct drawtex_state { GLuint VAO; - GLuint VBO; + struct gl_buffer_object *buf_obj; }; #define MAX_META_OPS_DEPTH 8 @@ -615,13 +616,15 @@ struct temp_texture * _mesa_meta_get_temp_depth_texture(struct gl_context *ctx); void -_mesa_meta_setup_vertex_objects(GLuint *VAO, GLuint *VBO, +_mesa_meta_setup_vertex_objects(struct gl_context *ctx, + GLuint *VAO, struct gl_buffer_object **buf_obj, bool use_generic_attributes, unsigned vertex_size, unsigned texcoord_size, unsigned color_size); void -_mesa_meta_setup_ff_tnl_for_blit(GLuint *VAO, GLuint *VBO, +_mesa_meta_setup_ff_tnl_for_blit(struct gl_context *ctx, + GLuint *VAO, struct gl_buffer_object **buf_obj, unsigned texcoord_size); void @@ -647,13 +650,14 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx, struct blit_shader_table *table); void -_mesa_meta_glsl_blit_cleanup(struct blit_state *blit); +_mesa_meta_glsl_blit_cleanup(struct gl_context *ctx, struct blit_state *blit); void _mesa_meta_blit_shader_table_cleanup(struct blit_shader_table *table); void -_mesa_meta_glsl_generate_mipmap_cleanup(struct gen_mipmap_state *mipmap); +_mesa_meta_glsl_generate_mipmap_cleanup(struct gl_context *ctx, + struct gen_mipmap_state *mipmap); void _mesa_meta_bind_fbo_image(GLenum target, GLenum attachment, diff --git a/lib/mesa/src/mesa/drivers/common/meta_blit.c b/lib/mesa/src/mesa/drivers/common/meta_blit.c index 7d5fde964..8a5a95b9d 100644 --- a/lib/mesa/src/mesa/drivers/common/meta_blit.c +++ b/lib/mesa/src/mesa/drivers/common/meta_blit.c @@ -533,7 +533,7 @@ setup_glsl_blit_framebuffer(struct gl_context *ctx, texcoord_size = 2 + (src_rb->Depth > 1 ? 1 : 0); - _mesa_meta_setup_vertex_objects(&blit->VAO, &blit->VBO, true, + _mesa_meta_setup_vertex_objects(ctx, &blit->VAO, &blit->buf_obj, true, 2, texcoord_size, 0); if (is_target_multisample && is_filter_scaled_resolve && is_scaled_blit) { @@ -659,8 +659,9 @@ blitframebuffer_texture(struct gl_context *ctx, do_depth); } else { - _mesa_meta_setup_ff_tnl_for_blit(&ctx->Meta->Blit.VAO, - &ctx->Meta->Blit.VBO, + _mesa_meta_setup_ff_tnl_for_blit(ctx, + &ctx->Meta->Blit.VAO, + &ctx->Meta->Blit.buf_obj, 2); } @@ -757,7 +758,8 @@ blitframebuffer_texture(struct gl_context *ctx, verts[3].tex[1] = t1; verts[3].tex[2] = readAtt->Zoffset; - _mesa_BufferSubData(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts); + _mesa_buffer_sub_data(ctx, blit->buf_obj, 0, sizeof(verts), verts, + __func__); } /* setup viewport */ @@ -972,13 +974,12 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx, } void -_mesa_meta_glsl_blit_cleanup(struct blit_state *blit) +_mesa_meta_glsl_blit_cleanup(struct gl_context *ctx, struct blit_state *blit) { if (blit->VAO) { _mesa_DeleteVertexArrays(1, &blit->VAO); blit->VAO = 0; - _mesa_DeleteBuffers(1, &blit->VBO); - blit->VBO = 0; + _mesa_reference_buffer_object(ctx, &blit->buf_obj, NULL); } _mesa_meta_blit_shader_table_cleanup(&blit->shaders_with_depth); diff --git a/lib/mesa/src/mesa/drivers/common/meta_generate_mipmap.c b/lib/mesa/src/mesa/drivers/common/meta_generate_mipmap.c index 9d3b9b6eb..b0e2f7e5a 100644 --- a/lib/mesa/src/mesa/drivers/common/meta_generate_mipmap.c +++ b/lib/mesa/src/mesa/drivers/common/meta_generate_mipmap.c @@ -62,6 +62,15 @@ fallback_required(struct gl_context *ctx, GLenum target, GLuint srcLevel; GLenum status; + /* GL_DRAW_FRAMEBUFFER does not exist in OpenGL ES 1.x, and since + * _mesa_meta_begin hasn't been called yet, we have to work-around API + * difficulties. The whole reason that GL_DRAW_FRAMEBUFFER is used instead + * of GL_FRAMEBUFFER is that the read framebuffer may be different. This + * is moot in OpenGL ES 1.x. + */ + const GLenum fbo_target = ctx->API == API_OPENGLES + ? GL_FRAMEBUFFER : GL_DRAW_FRAMEBUFFER; + /* check for fallbacks */ if (target == GL_TEXTURE_3D) { _mesa_perf_debug(ctx, MESA_DEBUG_SEVERITY_HIGH, @@ -102,13 +111,13 @@ fallback_required(struct gl_context *ctx, GLenum target, */ if (!mipmap->FBO) _mesa_GenFramebuffers(1, &mipmap->FBO); - _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, mipmap->FBO); + _mesa_BindFramebuffer(fbo_target, mipmap->FBO); - _mesa_meta_bind_fbo_image(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, baseImage, 0); + _mesa_meta_bind_fbo_image(fbo_target, GL_COLOR_ATTACHMENT0, baseImage, 0); - status = _mesa_CheckFramebufferStatus(GL_DRAW_FRAMEBUFFER); + status = _mesa_CheckFramebufferStatus(fbo_target); - _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, fboSave); + _mesa_BindFramebuffer(fbo_target, fboSave); if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { _mesa_perf_debug(ctx, MESA_DEBUG_SEVERITY_HIGH, @@ -120,17 +129,22 @@ fallback_required(struct gl_context *ctx, GLenum target, } void -_mesa_meta_glsl_generate_mipmap_cleanup(struct gen_mipmap_state *mipmap) +_mesa_meta_glsl_generate_mipmap_cleanup(struct gl_context *ctx, + struct gen_mipmap_state *mipmap) { if (mipmap->VAO == 0) return; _mesa_DeleteVertexArrays(1, &mipmap->VAO); mipmap->VAO = 0; - _mesa_DeleteBuffers(1, &mipmap->VBO); - mipmap->VBO = 0; + _mesa_reference_buffer_object(ctx, &mipmap->buf_obj, NULL); _mesa_DeleteSamplers(1, &mipmap->Sampler); mipmap->Sampler = 0; + if (mipmap->FBO != 0) { + _mesa_DeleteFramebuffers(1, &mipmap->FBO); + mipmap->FBO = 0; + } + _mesa_meta_blit_shader_table_cleanup(&mipmap->shaders); } @@ -192,11 +206,11 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target, * GenerateMipmap function. */ if (use_glsl_version) { - _mesa_meta_setup_vertex_objects(&mipmap->VAO, &mipmap->VBO, true, + _mesa_meta_setup_vertex_objects(ctx, &mipmap->VAO, &mipmap->buf_obj, true, 2, 4, 0); _mesa_meta_setup_blit_shader(ctx, target, false, &mipmap->shaders); } else { - _mesa_meta_setup_ff_tnl_for_blit(&mipmap->VAO, &mipmap->VBO, 3); + _mesa_meta_setup_ff_tnl_for_blit(ctx, &mipmap->VAO, &mipmap->buf_obj, 3); _mesa_set_enable(ctx, target, GL_TRUE); } @@ -331,8 +345,8 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target, verts[3].tex); /* upload vertex data */ - _mesa_BufferData(GL_ARRAY_BUFFER_ARB, sizeof(verts), - verts, GL_DYNAMIC_DRAW_ARB); + _mesa_buffer_data(ctx, mipmap->buf_obj, GL_NONE, sizeof(verts), verts, + GL_DYNAMIC_DRAW, __func__); _mesa_meta_bind_fbo_image(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, dstImage, layer); diff --git a/lib/mesa/src/mesa/drivers/common/meta_tex_subimage.c b/lib/mesa/src/mesa/drivers/common/meta_tex_subimage.c index 8b7521c0a..4adaad777 100644 --- a/lib/mesa/src/mesa/drivers/common/meta_tex_subimage.c +++ b/lib/mesa/src/mesa/drivers/common/meta_tex_subimage.c @@ -64,11 +64,12 @@ need_signed_unsigned_int_conversion(mesa_format mesaFormat, } static struct gl_texture_image * -create_texture_for_pbo(struct gl_context *ctx, bool create_pbo, - GLenum pbo_target, int width, int height, +create_texture_for_pbo(struct gl_context *ctx, + bool create_pbo, GLenum pbo_target, + int dims, int width, int height, int depth, GLenum format, GLenum type, const void *pixels, const struct gl_pixelstore_attrib *packing, - GLuint *tmp_pbo, GLuint *tmp_tex) + struct gl_buffer_object **tmp_pbo, GLuint *tmp_tex) { uint32_t pbo_format; GLenum internal_format; @@ -91,40 +92,45 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo, return NULL; /* Account for SKIP_PIXELS, SKIP_ROWS, ALIGNMENT, and SKIP_IMAGES */ - pixels = _mesa_image_address3d(packing, pixels, - width, height, format, type, 0, 0, 0); + uint32_t first_pixel = _mesa_image_offset(dims, packing, width, height, + format, type, + 0, 0, 0); + uint32_t last_pixel = _mesa_image_offset(dims, packing, width, height, + format, type, + depth-1, height-1, width); row_stride = _mesa_image_row_stride(packing, width, format, type); if (_mesa_is_bufferobj(packing->BufferObj)) { - *tmp_pbo = 0; + *tmp_pbo = NULL; buffer_obj = packing->BufferObj; + first_pixel += (intptr_t)pixels; } else { bool is_pixel_pack = pbo_target == GL_PIXEL_PACK_BUFFER; assert(create_pbo); - _mesa_GenBuffers(1, tmp_pbo); - - /* We are not doing this inside meta_begin/end. However, we know the - * client doesn't have the given target bound, so we can go ahead and - * squash it. We'll set it back when we're done. - */ - _mesa_BindBuffer(pbo_target, *tmp_pbo); + *tmp_pbo = ctx->Driver.NewBufferObject(ctx, 0xDEADBEEF); + if (*tmp_pbo == NULL) + return NULL; /* In case of GL_PIXEL_PACK_BUFFER, pass null pointer for the pixel - * data to avoid unnecessary data copying in _mesa_BufferData(). + * data to avoid unnecessary data copying in _mesa_buffer_data. */ if (is_pixel_pack) - _mesa_BufferData(pbo_target, row_stride * height, NULL, - GL_STREAM_READ); + _mesa_buffer_data(ctx, *tmp_pbo, GL_NONE, + last_pixel - first_pixel, + NULL, + GL_STREAM_READ, + __func__); else - _mesa_BufferData(pbo_target, row_stride * height, pixels, - GL_STREAM_DRAW); - - buffer_obj = packing->BufferObj; - pixels = NULL; - - _mesa_BindBuffer(pbo_target, 0); + _mesa_buffer_data(ctx, *tmp_pbo, GL_NONE, + last_pixel - first_pixel, + (char *)pixels + first_pixel, + GL_STREAM_DRAW, + __func__); + + buffer_obj = *tmp_pbo; + first_pixel = 0; } _mesa_GenTextures(1, tmp_tex); @@ -137,18 +143,25 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo, internal_format = _mesa_get_format_base_format(pbo_format); + /* The texture is addressed as a single very-tall image, so we + * need to pack the multiple image depths together taking the + * inter-image padding into account. + */ + int image_height = packing->ImageHeight == 0 ? height : packing->ImageHeight; + int full_height = image_height * (depth - 1) + height; + tex_image = _mesa_get_tex_image(ctx, tex_obj, tex_obj->Target, 0); - _mesa_init_teximage_fields(ctx, tex_image, width, height, 1, + _mesa_init_teximage_fields(ctx, tex_image, width, full_height, 1, 0, internal_format, pbo_format); read_only = pbo_target == GL_PIXEL_UNPACK_BUFFER; if (!ctx->Driver.SetTextureStorageForBufferObject(ctx, tex_obj, buffer_obj, - (intptr_t)pixels, + first_pixel, row_stride, read_only)) { _mesa_DeleteTextures(1, tmp_tex); - _mesa_DeleteBuffers(1, tmp_pbo); + _mesa_reference_buffer_object(ctx, tmp_pbo, NULL); return NULL; } @@ -164,8 +177,9 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, bool allocate_storage, bool create_pbo, const struct gl_pixelstore_attrib *packing) { - GLuint pbo = 0, pbo_tex = 0, fbos[2] = { 0, 0 }; - int full_height, image_height; + struct gl_buffer_object *pbo = NULL; + GLuint pbo_tex = 0, fbos[2] = { 0, 0 }; + int image_height; struct gl_texture_image *pbo_tex_image; GLenum status; bool success = false; @@ -196,11 +210,10 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, * property. */ image_height = packing->ImageHeight == 0 ? height : packing->ImageHeight; - full_height = image_height * (depth - 1) + height; pbo_tex_image = create_texture_for_pbo(ctx, create_pbo, GL_PIXEL_UNPACK_BUFFER, - width, full_height, + dims, width, height, depth, format, type, pixels, packing, &pbo, &pbo_tex); if (!pbo_tex_image) @@ -268,7 +281,7 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, fail: _mesa_DeleteFramebuffers(2, fbos); _mesa_DeleteTextures(1, &pbo_tex); - _mesa_DeleteBuffers(1, &pbo); + _mesa_reference_buffer_object(ctx, &pbo, NULL); _mesa_meta_end(ctx); @@ -283,8 +296,9 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, GLenum format, GLenum type, const void *pixels, const struct gl_pixelstore_attrib *packing) { - GLuint pbo = 0, pbo_tex = 0, fbos[2] = { 0, 0 }; - int full_height, image_height; + struct gl_buffer_object *pbo = NULL; + GLuint pbo_tex = 0, fbos[2] = { 0, 0 }; + int image_height; struct gl_texture_image *pbo_tex_image; struct gl_renderbuffer *rb = NULL; GLenum dstBaseFormat = _mesa_unpack_format_to_base_format(format); @@ -331,10 +345,9 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, * property. */ image_height = packing->ImageHeight == 0 ? height : packing->ImageHeight; - full_height = image_height * (depth - 1) + height; pbo_tex_image = create_texture_for_pbo(ctx, false, GL_PIXEL_PACK_BUFFER, - width, full_height * depth, + dims, width, height, depth, format, type, pixels, packing, &pbo, &pbo_tex); if (!pbo_tex_image) @@ -441,7 +454,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, fail: _mesa_DeleteFramebuffers(2, fbos); _mesa_DeleteTextures(1, &pbo_tex); - _mesa_DeleteBuffers(1, &pbo); + _mesa_reference_buffer_object(ctx, &pbo, NULL); _mesa_meta_end(ctx); diff --git a/lib/mesa/src/mesa/drivers/dri/common/xmlconfig.c b/lib/mesa/src/mesa/drivers/dri/common/xmlconfig.c index f17693e73..534920e44 100644 --- a/lib/mesa/src/mesa/drivers/dri/common/xmlconfig.c +++ b/lib/mesa/src/mesa/drivers/dri/common/xmlconfig.c @@ -59,6 +59,9 @@ extern char *program_invocation_name, *program_invocation_short_name; #elif defined(__NetBSD__) && defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 106000100) # include <stdlib.h> # define GET_PROGRAM_NAME() getprogname() +#elif defined(__DragonFly__) +# include <stdlib.h> +# define GET_PROGRAM_NAME() getprogname() #elif defined(__APPLE__) # include <stdlib.h> # define GET_PROGRAM_NAME() getprogname() diff --git a/lib/mesa/src/mesa/drivers/dri/i965/brw_context.c b/lib/mesa/src/mesa/drivers/dri/i965/brw_context.c index f59e47413..2e7b7ed46 100644 --- a/lib/mesa/src/mesa/drivers/dri/i965/brw_context.c +++ b/lib/mesa/src/mesa/drivers/dri/i965/brw_context.c @@ -189,6 +189,24 @@ intel_update_state(struct gl_context * ctx, GLuint new_state) brw_render_cache_set_check_flush(brw, tex_obj->mt->bo); } + /* Resolve color for each active shader image. */ + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { + const struct gl_shader *shader = ctx->_Shader->CurrentProgram[i] ? + ctx->_Shader->CurrentProgram[i]->_LinkedShaders[i] : NULL; + + if (unlikely(shader && shader->NumImages)) { + for (unsigned j = 0; j < shader->NumImages; j++) { + struct gl_image_unit *u = &ctx->ImageUnits[shader->ImageUnits[j]]; + tex_obj = intel_texture_object(u->TexObj); + + if (tex_obj && tex_obj->mt) { + intel_miptree_resolve_color(brw, tex_obj->mt); + brw_render_cache_set_check_flush(brw, tex_obj->mt->bo); + } + } + } + } + _mesa_lock_context_textures(ctx); } diff --git a/lib/mesa/src/mesa/drivers/dri/i965/brw_fs.cpp b/lib/mesa/src/mesa/drivers/dri/i965/brw_fs.cpp index 4e9c96c39..12bf0c855 100644 --- a/lib/mesa/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/lib/mesa/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -1039,33 +1039,19 @@ fs_visitor::emit_linterp(const fs_reg &attr, const fs_reg &interp, } void -fs_visitor::emit_general_interpolation(fs_reg attr, const char *name, +fs_visitor::emit_general_interpolation(fs_reg *attr, const char *name, const glsl_type *type, glsl_interp_qualifier interpolation_mode, - int location, bool mod_centroid, + int *location, bool mod_centroid, bool mod_sample) { - attr.type = brw_type_for_base_type(type->get_scalar_type()); - assert(stage == MESA_SHADER_FRAGMENT); brw_wm_prog_data *prog_data = (brw_wm_prog_data*) this->prog_data; brw_wm_prog_key *key = (brw_wm_prog_key*) this->key; - unsigned int array_elements; - - if (type->is_array()) { - array_elements = type->length; - if (array_elements == 0) { - fail("dereferenced array '%s' has length 0\n", name); - } - type = type->fields.array; - } else { - array_elements = 1; - } - if (interpolation_mode == INTERP_QUALIFIER_NONE) { bool is_gl_Color = - location == VARYING_SLOT_COL0 || location == VARYING_SLOT_COL1; + *location == VARYING_SLOT_COL0 || *location == VARYING_SLOT_COL1; if (key->flat_shade && is_gl_Color) { interpolation_mode = INTERP_QUALIFIER_FLAT; } else { @@ -1073,71 +1059,86 @@ fs_visitor::emit_general_interpolation(fs_reg attr, const char *name, } } - for (unsigned int i = 0; i < array_elements; i++) { - for (unsigned int j = 0; j < type->matrix_columns; j++) { - if (prog_data->urb_setup[location] == -1) { - /* If there's no incoming setup data for this slot, don't - * emit interpolation for it. - */ - attr = offset(attr, bld, type->vector_elements); - location++; - continue; - } + if (type->is_array() || type->is_matrix()) { + const glsl_type *elem_type = glsl_get_array_element(type); + const unsigned length = glsl_get_length(type); - if (interpolation_mode == INTERP_QUALIFIER_FLAT) { - /* Constant interpolation (flat shading) case. The SF has - * handed us defined values in only the constant offset - * field of the setup reg. - */ - for (unsigned int k = 0; k < type->vector_elements; k++) { - struct brw_reg interp = interp_reg(location, k); - interp = suboffset(interp, 3); - interp.type = attr.type; - bld.emit(FS_OPCODE_CINTERP, attr, fs_reg(interp)); - attr = offset(attr, bld, 1); - } - } else { - /* Smooth/noperspective interpolation case. */ - for (unsigned int k = 0; k < type->vector_elements; k++) { - struct brw_reg interp = interp_reg(location, k); - if (devinfo->needs_unlit_centroid_workaround && mod_centroid) { - /* Get the pixel/sample mask into f0 so that we know - * which pixels are lit. Then, for each channel that is - * unlit, replace the centroid data with non-centroid - * data. - */ - bld.emit(FS_OPCODE_MOV_DISPATCH_TO_FLAGS); - - fs_inst *inst; - inst = emit_linterp(attr, fs_reg(interp), interpolation_mode, - false, false); - inst->predicate = BRW_PREDICATE_NORMAL; - inst->predicate_inverse = true; - if (devinfo->has_pln) - inst->no_dd_clear = true; - - inst = emit_linterp(attr, fs_reg(interp), interpolation_mode, - mod_centroid && !key->persample_shading, - mod_sample || key->persample_shading); - inst->predicate = BRW_PREDICATE_NORMAL; - inst->predicate_inverse = false; - if (devinfo->has_pln) - inst->no_dd_check = true; + for (unsigned i = 0; i < length; i++) { + emit_general_interpolation(attr, name, elem_type, interpolation_mode, + location, mod_centroid, mod_sample); + } + } else if (type->is_record()) { + for (unsigned i = 0; i < type->length; i++) { + const glsl_type *field_type = type->fields.structure[i].type; + emit_general_interpolation(attr, name, field_type, interpolation_mode, + location, mod_centroid, mod_sample); + } + } else { + assert(type->is_scalar() || type->is_vector()); - } else { - emit_linterp(attr, fs_reg(interp), interpolation_mode, - mod_centroid && !key->persample_shading, - mod_sample || key->persample_shading); - } - if (devinfo->gen < 6 && interpolation_mode == INTERP_QUALIFIER_SMOOTH) { - bld.MUL(attr, attr, this->pixel_w); - } - attr = offset(attr, bld, 1); - } + if (prog_data->urb_setup[*location] == -1) { + /* If there's no incoming setup data for this slot, don't + * emit interpolation for it. + */ + *attr = offset(*attr, bld, type->vector_elements); + (*location)++; + return; + } - } - location++; + attr->type = brw_type_for_base_type(type->get_scalar_type()); + + if (interpolation_mode == INTERP_QUALIFIER_FLAT) { + /* Constant interpolation (flat shading) case. The SF has + * handed us defined values in only the constant offset + * field of the setup reg. + */ + for (unsigned int i = 0; i < type->vector_elements; i++) { + struct brw_reg interp = interp_reg(*location, i); + interp = suboffset(interp, 3); + interp.type = attr->type; + bld.emit(FS_OPCODE_CINTERP, *attr, fs_reg(interp)); + *attr = offset(*attr, bld, 1); + } + } else { + /* Smooth/noperspective interpolation case. */ + for (unsigned int i = 0; i < type->vector_elements; i++) { + struct brw_reg interp = interp_reg(*location, i); + if (devinfo->needs_unlit_centroid_workaround && mod_centroid) { + /* Get the pixel/sample mask into f0 so that we know + * which pixels are lit. Then, for each channel that is + * unlit, replace the centroid data with non-centroid + * data. + */ + bld.emit(FS_OPCODE_MOV_DISPATCH_TO_FLAGS); + + fs_inst *inst; + inst = emit_linterp(*attr, fs_reg(interp), interpolation_mode, + false, false); + inst->predicate = BRW_PREDICATE_NORMAL; + inst->predicate_inverse = true; + if (devinfo->has_pln) + inst->no_dd_clear = true; + + inst = emit_linterp(*attr, fs_reg(interp), interpolation_mode, + mod_centroid && !key->persample_shading, + mod_sample || key->persample_shading); + inst->predicate = BRW_PREDICATE_NORMAL; + inst->predicate_inverse = false; + if (devinfo->has_pln) + inst->no_dd_check = true; + + } else { + emit_linterp(*attr, fs_reg(interp), interpolation_mode, + mod_centroid && !key->persample_shading, + mod_sample || key->persample_shading); + } + if (devinfo->gen < 6 && interpolation_mode == INTERP_QUALIFIER_SMOOTH) { + bld.MUL(*attr, *attr, this->pixel_w); + } + *attr = offset(*attr, bld, 1); + } } + (*location)++; } } diff --git a/lib/mesa/src/mesa/drivers/dri/i965/brw_fs.h b/lib/mesa/src/mesa/drivers/dri/i965/brw_fs.h index 975183e99..afb8eb1f1 100644 --- a/lib/mesa/src/mesa/drivers/dri/i965/brw_fs.h +++ b/lib/mesa/src/mesa/drivers/dri/i965/brw_fs.h @@ -197,10 +197,10 @@ public: fs_reg *emit_frontfacing_interpolation(); fs_reg *emit_samplepos_setup(); fs_reg *emit_sampleid_setup(); - void emit_general_interpolation(fs_reg attr, const char *name, + void emit_general_interpolation(fs_reg *attr, const char *name, const glsl_type *type, glsl_interp_qualifier interpolation_mode, - int location, bool mod_centroid, + int *location, bool mod_centroid, bool mod_sample); fs_reg *emit_vs_system_value(int location); void emit_interpolation_setup_gen4(); @@ -240,6 +240,8 @@ public: void emit_nir_code(); void nir_setup_inputs(nir_shader *shader); + void nir_setup_single_output_varying(fs_reg ®, const glsl_type *type, + unsigned &location); void nir_setup_outputs(nir_shader *shader); void nir_setup_uniforms(nir_shader *shader); void nir_setup_uniform(nir_variable *var); diff --git a/lib/mesa/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/lib/mesa/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index c726c72eb..5ebbf7033 100644 --- a/lib/mesa/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/lib/mesa/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -105,9 +105,10 @@ fs_visitor::nir_setup_inputs(nir_shader *shader) emit_percomp(bld, fs_inst(BRW_OPCODE_MOV, bld.dispatch_width(), input, reg), 0xF); } else { - emit_general_interpolation(input, var->name, var->type, + int location = var->data.location; + emit_general_interpolation(&input, var->name, var->type, (glsl_interp_qualifier) var->data.interpolation, - var->data.location, var->data.centroid, + &location, var->data.centroid, var->data.sample); } break; @@ -116,6 +117,32 @@ fs_visitor::nir_setup_inputs(nir_shader *shader) } void +fs_visitor::nir_setup_single_output_varying(fs_reg ®, + const glsl_type *type, + unsigned &location) +{ + if (type->is_array() || type->is_matrix()) { + const struct glsl_type *elem_type = glsl_get_array_element(type); + const unsigned length = glsl_get_length(type); + + for (unsigned i = 0; i < length; i++) { + nir_setup_single_output_varying(reg, elem_type, location); + } + } else if (type->is_record()) { + for (unsigned i = 0; i < type->length; i++) { + const struct glsl_type *field_type = type->fields.structure[i].type; + nir_setup_single_output_varying(reg, field_type, location); + } + } else { + assert(type->is_scalar() || type->is_vector()); + this->outputs[location] = reg; + this->output_components[location] = type->vector_elements; + reg = offset(reg, bld, 4); + location++; + } +} + +void fs_visitor::nir_setup_outputs(nir_shader *shader) { brw_wm_prog_key *key = (brw_wm_prog_key*) this->key; @@ -130,13 +157,11 @@ fs_visitor::nir_setup_outputs(nir_shader *shader) : var->type->vector_elements; switch (stage) { - case MESA_SHADER_VERTEX: - for (int i = 0; i < ALIGN(type_size(var->type), 4) / 4; i++) { - int output = var->data.location + i; - this->outputs[output] = offset(reg, bld, 4 * i); - this->output_components[output] = vector_elements; - } + case MESA_SHADER_VERTEX: { + unsigned location = var->data.location; + nir_setup_single_output_varying(reg, var->type, location); break; + } case MESA_SHADER_FRAGMENT: if (var->data.index > 0) { assert(var->data.location == FRAG_RESULT_DATA0); diff --git a/lib/mesa/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c b/lib/mesa/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c index f5ecbb549..c3d58d247 100644 --- a/lib/mesa/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c +++ b/lib/mesa/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c @@ -54,8 +54,9 @@ #include "brw_blorp.h" struct brw_fast_clear_state { + struct gl_buffer_object *buf_obj; + struct gl_vertex_array_object *array_obj; GLuint vao; - GLuint vbo; GLuint shader_prog; GLint color_location; }; @@ -64,11 +65,11 @@ static bool brw_fast_clear_init(struct brw_context *brw) { struct brw_fast_clear_state *clear; + struct gl_context *ctx = &brw->ctx; if (brw->fast_clear_state) { clear = brw->fast_clear_state; _mesa_BindVertexArray(clear->vao); - _mesa_BindBuffer(GL_ARRAY_BUFFER, clear->vbo); return true; } @@ -79,10 +80,21 @@ brw_fast_clear_init(struct brw_context *brw) memset(clear, 0, sizeof *clear); _mesa_GenVertexArrays(1, &clear->vao); _mesa_BindVertexArray(clear->vao); - _mesa_GenBuffers(1, &clear->vbo); - _mesa_BindBuffer(GL_ARRAY_BUFFER, clear->vbo); - _mesa_VertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, 0); - _mesa_EnableVertexAttribArray(0); + + clear->buf_obj = ctx->Driver.NewBufferObject(ctx, 0xDEADBEEF); + if (clear->buf_obj == NULL) + return false; + + clear->array_obj = _mesa_lookup_vao(ctx, clear->vao); + assert(clear->array_obj != NULL); + + _mesa_update_array_format(ctx, clear->array_obj, VERT_ATTRIB_GENERIC(0), + 2, GL_FLOAT, GL_RGBA, GL_FALSE, GL_FALSE, GL_FALSE, + 0, true); + _mesa_bind_vertex_buffer(ctx, clear->array_obj, VERT_ATTRIB_GENERIC(0), + clear->buf_obj, 0, sizeof(float) * 2); + _mesa_enable_vertex_array_attrib(ctx, clear->array_obj, + VERT_ATTRIB_GENERIC(0)); return true; } @@ -150,7 +162,7 @@ brw_meta_fast_clear_free(struct brw_context *brw) _mesa_make_current(&brw->ctx, NULL, NULL); _mesa_DeleteVertexArrays(1, &clear->vao); - _mesa_DeleteBuffers(1, &clear->vbo); + _mesa_reference_buffer_object(&brw->ctx, &clear->buf_obj, NULL); _mesa_DeleteProgram(clear->shader_prog); free(clear); @@ -165,8 +177,10 @@ struct rect { }; static void -brw_draw_rectlist(struct gl_context *ctx, struct rect *rect, int num_instances) +brw_draw_rectlist(struct brw_context *brw, struct rect *rect, int num_instances) { + struct gl_context *ctx = &brw->ctx; + struct brw_fast_clear_state *clear = brw->fast_clear_state; int start = 0, count = 3; struct _mesa_prim prim; float verts[6]; @@ -179,8 +193,8 @@ brw_draw_rectlist(struct gl_context *ctx, struct rect *rect, int num_instances) verts[5] = rect->y0; /* upload new vertex data */ - _mesa_BufferData(GL_ARRAY_BUFFER_ARB, sizeof(verts), verts, - GL_DYNAMIC_DRAW_ARB); + _mesa_buffer_data(ctx, clear->buf_obj, GL_NONE, sizeof(verts), verts, + GL_DYNAMIC_DRAW, __func__); if (ctx->NewState) _mesa_update_state(ctx); @@ -582,14 +596,14 @@ brw_meta_fast_clear(struct brw_context *brw, struct gl_framebuffer *fb, _mesa_meta_drawbuffers_from_bitfield(fast_clear_buffers); brw_bind_rep_write_shader(brw, (float *) fast_clear_color); set_fast_clear_op(brw, GEN7_PS_RENDER_TARGET_FAST_CLEAR_ENABLE); - brw_draw_rectlist(ctx, &fast_clear_rect, layers); + brw_draw_rectlist(brw, &fast_clear_rect, layers); set_fast_clear_op(brw, 0); } if (rep_clear_buffers) { _mesa_meta_drawbuffers_from_bitfield(rep_clear_buffers); brw_bind_rep_write_shader(brw, ctx->Color.ClearColor.f); - brw_draw_rectlist(ctx, &clear_rect, layers); + brw_draw_rectlist(brw, &clear_rect, layers); } /* Now set the mts we cleared to INTEL_FAST_CLEAR_STATE_CLEAR so we'll @@ -701,7 +715,7 @@ brw_meta_resolve_color(struct brw_context *brw, mt->fast_clear_state = INTEL_FAST_CLEAR_STATE_RESOLVED; get_resolve_rect(brw, mt, &rect); - brw_draw_rectlist(ctx, &rect, 1); + brw_draw_rectlist(brw, &rect, 1); set_fast_clear_op(brw, 0); use_rectlist(brw, false); diff --git a/lib/mesa/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c b/lib/mesa/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c index aa6df16eb..65f3bdd23 100644 --- a/lib/mesa/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c +++ b/lib/mesa/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c @@ -279,7 +279,8 @@ setup_program(struct brw_context *brw, bool msaa_tex) char *fs_source; const struct sampler_and_fetch *sampler = &samplers[msaa_tex]; - _mesa_meta_setup_vertex_objects(&blit->VAO, &blit->VBO, true, 2, 2, 0); + _mesa_meta_setup_vertex_objects(&brw->ctx, &blit->VAO, &blit->buf_obj, true, + 2, 2, 0); GLuint *prog_id = &brw->meta_stencil_blit_programs[msaa_tex]; @@ -360,7 +361,7 @@ adjust_mip_level(const struct intel_mipmap_tree *mt, } static void -prepare_vertex_data(void) +prepare_vertex_data(struct gl_context *ctx, struct gl_buffer_object *buf_obj) { static const struct vertex verts[] = { { .x = -1.0f, .y = -1.0f }, @@ -368,7 +369,7 @@ prepare_vertex_data(void) { .x = 1.0f, .y = 1.0f }, { .x = -1.0f, .y = 1.0f } }; - _mesa_BufferSubData(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts); + _mesa_buffer_sub_data(ctx, buf_obj, 0, sizeof(verts), verts, __func__); } static bool @@ -448,7 +449,7 @@ brw_meta_stencil_blit(struct brw_context *brw, _mesa_Uniform1i(_mesa_GetUniformLocation(prog, "dst_num_samples"), dst_mt->num_samples); - prepare_vertex_data(); + prepare_vertex_data(ctx, ctx->Meta->Blit.buf_obj); _mesa_set_viewport(ctx, 0, dims.dst_x0, dims.dst_y0, dims.dst_x1 - dims.dst_x0, dims.dst_y1 - dims.dst_y0); _mesa_ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); diff --git a/lib/mesa/src/mesa/drivers/dri/i965/brw_surface_formats.c b/lib/mesa/src/mesa/drivers/dri/i965/brw_surface_formats.c index a33fd88a0..b5e8edf89 100644 --- a/lib/mesa/src/mesa/drivers/dri/i965/brw_surface_formats.c +++ b/lib/mesa/src/mesa/drivers/dri/i965/brw_surface_formats.c @@ -379,6 +379,7 @@ brw_format_for_mesa_format(mesa_format mesa_format) [MESA_FORMAT_A8R8G8B8_SRGB] = 0, [MESA_FORMAT_R8G8B8A8_SRGB] = BRW_SURFACEFORMAT_R8G8B8A8_UNORM_SRGB, [MESA_FORMAT_X8R8G8B8_SRGB] = 0, + [MESA_FORMAT_B8G8R8X8_SRGB] = BRW_SURFACEFORMAT_B8G8R8X8_UNORM_SRGB, [MESA_FORMAT_L_SRGB8] = BRW_SURFACEFORMAT_L8_UNORM_SRGB, [MESA_FORMAT_L8A8_SRGB] = BRW_SURFACEFORMAT_L8A8_UNORM_SRGB, [MESA_FORMAT_A8L8_SRGB] = 0, @@ -614,6 +615,10 @@ brw_init_surface_formats(struct brw_context *brw) */ render = BRW_SURFACEFORMAT_B8G8R8A8_UNORM; break; + case BRW_SURFACEFORMAT_B8G8R8X8_UNORM_SRGB: + if (gen < tinfo->render_target) + render = BRW_SURFACEFORMAT_B8G8R8A8_UNORM_SRGB; + break; case BRW_SURFACEFORMAT_R8G8B8X8_UNORM: render = BRW_SURFACEFORMAT_R8G8B8A8_UNORM; break; diff --git a/lib/mesa/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/lib/mesa/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index 1f97bacf7..b8e1f70a6 100644 --- a/lib/mesa/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/lib/mesa/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -981,7 +981,7 @@ brw_upload_wm_abo_surfaces(struct brw_context *brw) { struct gl_context *ctx = &brw->ctx; /* _NEW_PROGRAM */ - struct gl_shader_program *prog = ctx->Shader._CurrentFragmentProgram; + struct gl_shader_program *prog = ctx->_Shader->_CurrentFragmentProgram; if (prog) { /* BRW_NEW_FS_PROG_DATA */ @@ -1257,7 +1257,7 @@ brw_upload_wm_image_surfaces(struct brw_context *brw) { struct gl_context *ctx = &brw->ctx; /* BRW_NEW_FRAGMENT_PROGRAM */ - struct gl_shader_program *prog = ctx->Shader._CurrentFragmentProgram; + struct gl_shader_program *prog = ctx->_Shader->_CurrentFragmentProgram; if (prog) { /* BRW_NEW_FS_PROG_DATA, BRW_NEW_IMAGE_UNITS, _NEW_TEXTURE */ diff --git a/lib/mesa/src/mesa/main/glformats.c b/lib/mesa/src/mesa/main/glformats.c index 629a0a45f..a6058a5f8 100644 --- a/lib/mesa/src/mesa/main/glformats.c +++ b/lib/mesa/src/mesa/main/glformats.c @@ -2018,12 +2018,18 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx, * \return error code, or GL_NO_ERROR. */ GLenum -_mesa_es_error_check_format_and_type(GLenum format, GLenum type, +_mesa_es_error_check_format_and_type(const struct gl_context *ctx, + GLenum format, GLenum type, unsigned dimensions) { GLboolean type_valid = GL_TRUE; switch (format) { + case GL_RED: + case GL_RG: + if (ctx->API == API_OPENGLES || !ctx->Extensions.ARB_texture_rg) + return GL_INVALID_VALUE; + /* fallthrough */ case GL_ALPHA: case GL_LUMINANCE: case GL_LUMINANCE_ALPHA: diff --git a/lib/mesa/src/mesa/main/glformats.h b/lib/mesa/src/mesa/main/glformats.h index 84328f29f..046aec3d9 100644 --- a/lib/mesa/src/mesa/main/glformats.h +++ b/lib/mesa/src/mesa/main/glformats.h @@ -124,7 +124,8 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx, GLenum format, GLenum type); extern GLenum -_mesa_es_error_check_format_and_type(GLenum format, GLenum type, +_mesa_es_error_check_format_and_type(const struct gl_context *ctx, + GLenum format, GLenum type, unsigned dimensions); extern GLenum diff --git a/lib/mesa/src/mesa/main/readpix.c b/lib/mesa/src/mesa/main/readpix.c index 18ab06afd..dfbbfac85 100644 --- a/lib/mesa/src/mesa/main/readpix.c +++ b/lib/mesa/src/mesa/main/readpix.c @@ -1043,7 +1043,7 @@ _mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height, _mesa_get_color_read_type(ctx) == type) { err = GL_NO_ERROR; } else if (ctx->Version < 30) { - err = _mesa_es_error_check_format_and_type(format, type, 2); + err = _mesa_es_error_check_format_and_type(ctx, format, type, 2); if (err == GL_NO_ERROR) { if (type == GL_FLOAT || type == GL_HALF_FLOAT_OES) { err = GL_INVALID_OPERATION; diff --git a/lib/mesa/src/mesa/main/shader_query.cpp b/lib/mesa/src/mesa/main/shader_query.cpp index 0e13572bb..06f27aceb 100644 --- a/lib/mesa/src/mesa/main/shader_query.cpp +++ b/lib/mesa/src/mesa/main/shader_query.cpp @@ -776,13 +776,18 @@ program_resource_location(struct gl_shader_program *shProg, * and user-defined attributes. */ switch (res->Type) { - case GL_PROGRAM_INPUT: + case GL_PROGRAM_INPUT: { + const ir_variable *var = RESOURCE_VAR(res); + /* If the input is an array, fail if the index is out of bounds. */ if (array_index > 0 - && array_index >= RESOURCE_VAR(res)->type->length) { + && array_index >= var->type->length) { return -1; } - return RESOURCE_VAR(res)->data.location + array_index - VERT_ATTRIB_GENERIC0; + return (var->data.location + + (array_index * var->type->without_array()->matrix_columns) - + VERT_ATTRIB_GENERIC0); + } case GL_PROGRAM_OUTPUT: /* If the output is an array, fail if the index is out of bounds. */ if (array_index > 0 diff --git a/lib/mesa/src/mesa/main/texgetimage.c b/lib/mesa/src/mesa/main/texgetimage.c index 303a01fe9..6c331482a 100644 --- a/lib/mesa/src/mesa/main/texgetimage.c +++ b/lib/mesa/src/mesa/main/texgetimage.c @@ -88,12 +88,6 @@ get_tex_depth(struct gl_context *ctx, GLuint dimensions, return; } - if (texImage->TexObject->Target == GL_TEXTURE_1D_ARRAY) { - depth = height; - height = 1; - } - - assert(zoffset + depth <= texImage->Depth); for (img = 0; img < depth; img++) { GLubyte *srcMap; GLint srcRowStride; @@ -141,7 +135,6 @@ get_tex_depth_stencil(struct gl_context *ctx, GLuint dimensions, assert(type == GL_UNSIGNED_INT_24_8 || type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV); - assert(zoffset + depth <= texImage->Depth); for (img = 0; img < depth; img++) { GLubyte *srcMap; GLint rowstride; @@ -233,7 +226,6 @@ get_tex_ycbcr(struct gl_context *ctx, GLuint dimensions, { GLint img, row; - assert(zoffset + depth <= texImage->Depth); for (img = 0; img < depth; img++) { GLubyte *srcMap; GLint rowstride; @@ -432,13 +424,6 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions, bool needsRebase; void *rgba = NULL; - if (texImage->TexObject->Target == GL_TEXTURE_1D_ARRAY) { - depth = height; - height = 1; - zoffset = yoffset; - yoffset = 0; - } - /* Depending on the base format involved we may need to apply a rebase * transform (for example: if we download to a Luminance format we want * G=0 and B=0). @@ -738,6 +723,17 @@ _mesa_GetTexSubImage_sw(struct gl_context *ctx, pixels = ADD_POINTERS(buf, pixels); } + /* for all array textures, the Z axis selects the layer */ + if (texImage->TexObject->Target == GL_TEXTURE_1D_ARRAY) { + depth = height; + height = 1; + zoffset = yoffset; + yoffset = 0; + assert(zoffset + depth <= texImage->Height); + } else { + assert(zoffset + depth <= texImage->Depth); + } + if (get_tex_memcpy(ctx, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels, texImage)) { /* all done */ diff --git a/lib/mesa/src/mesa/main/teximage.c b/lib/mesa/src/mesa/main/teximage.c index 24a594bbd..ab60a2fa5 100644 --- a/lib/mesa/src/mesa/main/teximage.c +++ b/lib/mesa/src/mesa/main/teximage.c @@ -1616,7 +1616,7 @@ texture_format_error_check_gles(struct gl_context *ctx, GLenum format, } } else { - err = _mesa_es_error_check_format_and_type(format, type, dimensions); + err = _mesa_es_error_check_format_and_type(ctx, format, type, dimensions); if (err != GL_NO_ERROR) { _mesa_error(ctx, err, "%s(format = %s, type = %s)", callerName, _mesa_enum_to_string(format), diff --git a/lib/mesa/src/mesa/main/varray.c b/lib/mesa/src/mesa/main/varray.c index 3bab98505..962bc3c7e 100644 --- a/lib/mesa/src/mesa/main/varray.c +++ b/lib/mesa/src/mesa/main/varray.c @@ -154,12 +154,12 @@ vertex_attrib_binding(struct gl_context *ctx, * Binds a buffer object to the vertex buffer binding point given by index, * and sets the Offset and Stride fields. */ -static void -bind_vertex_buffer(struct gl_context *ctx, - struct gl_vertex_array_object *vao, - GLuint index, - struct gl_buffer_object *vbo, - GLintptr offset, GLsizei stride) +void +_mesa_bind_vertex_buffer(struct gl_context *ctx, + struct gl_vertex_array_object *vao, + GLuint index, + struct gl_buffer_object *vbo, + GLintptr offset, GLsizei stride) { struct gl_vertex_buffer_binding *binding = &vao->VertexBinding[index]; @@ -248,6 +248,52 @@ get_legal_types_mask(const struct gl_context *ctx) /** + * \param attrib The index of the attribute array + * \param size Components per element (1, 2, 3 or 4) + * \param type Datatype of each component (GL_FLOAT, GL_INT, etc) + * \param format Either GL_RGBA or GL_BGRA. + * \param normalized Whether integer types are converted to floats in [-1, 1] + * \param integer Integer-valued values (will not be normalized to [-1, 1]) + * \param doubles Double values not reduced to floats + * \param relativeOffset Offset of the first element relative to the binding + * offset. + * \param flush_verties Should \c FLUSH_VERTICES be invoked before updating + * state? + */ +void +_mesa_update_array_format(struct gl_context *ctx, + struct gl_vertex_array_object *vao, + GLuint attrib, GLint size, GLenum type, + GLenum format, GLboolean normalized, + GLboolean integer, GLboolean doubles, + GLuint relativeOffset, bool flush_vertices) +{ + struct gl_vertex_attrib_array *const array = &vao->VertexAttrib[attrib]; + GLint elementSize; + + assert(size <= 4); + + if (flush_vertices) { + FLUSH_VERTICES(ctx, 0); + } + + elementSize = _mesa_bytes_per_vertex_attrib(size, type); + assert(elementSize != -1); + + array->Size = size; + array->Type = type; + array->Format = format; + array->Normalized = normalized; + array->Integer = integer; + array->Doubles = doubles; + array->RelativeOffset = relativeOffset; + array->_ElementSize = elementSize; + + vao->NewArrays |= VERT_BIT(attrib); + ctx->NewState |= _NEW_ARRAY; +} + +/** * Does error checking and updates the format in an attrib array. * * Called by update_array() and VertexAttrib*Format(). @@ -274,9 +320,7 @@ update_array_format(struct gl_context *ctx, GLboolean normalized, GLboolean integer, GLboolean doubles, GLuint relativeOffset) { - struct gl_vertex_attrib_array *array; GLbitfield typeBit; - GLint elementSize; GLenum format = GL_RGBA; if (ctx->Array.LegalTypesMask == 0 || ctx->Array.LegalTypesMaskAPI != ctx->API) { @@ -377,23 +421,9 @@ update_array_format(struct gl_context *ctx, return false; } - assert(size <= 4); - - elementSize = _mesa_bytes_per_vertex_attrib(size, type); - assert(elementSize != -1); - - array = &vao->VertexAttrib[attrib]; - array->Size = size; - array->Type = type; - array->Format = format; - array->Normalized = normalized; - array->Integer = integer; - array->Doubles = doubles; - array->RelativeOffset = relativeOffset; - array->_ElementSize = elementSize; - - vao->NewArrays |= VERT_BIT(attrib); - ctx->NewState |= _NEW_ARRAY; + _mesa_update_array_format(ctx, vao, attrib, size, type, format, + normalized, integer, doubles, relativeOffset, + false); return true; } @@ -491,8 +521,9 @@ update_array(struct gl_context *ctx, /* Update the vertex buffer binding */ effectiveStride = stride != 0 ? stride : array->_ElementSize; - bind_vertex_buffer(ctx, ctx->Array.VAO, attrib, ctx->Array.ArrayBufferObj, - (GLintptr) ptr, effectiveStride); + _mesa_bind_vertex_buffer(ctx, ctx->Array.VAO, attrib, + ctx->Array.ArrayBufferObj, (GLintptr) ptr, + effectiveStride); } @@ -735,10 +766,26 @@ _mesa_VertexAttribLPointer(GLuint index, GLint size, GLenum type, update_array(ctx, "glVertexAttribLPointer", VERT_ATTRIB_GENERIC(index), legalTypes, 1, 4, - size, type, stride, GL_TRUE, GL_FALSE, GL_TRUE, ptr); + size, type, stride, GL_FALSE, GL_FALSE, GL_TRUE, ptr); } +void +_mesa_enable_vertex_array_attrib(struct gl_context *ctx, + struct gl_vertex_array_object *vao, + unsigned attrib) +{ + assert(attrib < ARRAY_SIZE(vao->VertexAttrib)); + + if (!vao->VertexAttrib[attrib].Enabled) { + /* was disabled, now being enabled */ + FLUSH_VERTICES(ctx, _NEW_ARRAY); + vao->VertexAttrib[attrib].Enabled = GL_TRUE; + vao->_Enabled |= VERT_BIT(attrib); + vao->NewArrays |= VERT_BIT(attrib); + } +} + static void enable_vertex_array_attrib(struct gl_context *ctx, struct gl_vertex_array_object *vao, @@ -750,15 +797,7 @@ enable_vertex_array_attrib(struct gl_context *ctx, return; } - assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(vao->VertexAttrib)); - - if (!vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) { - /* was disabled, now being enabled */ - FLUSH_VERTICES(ctx, _NEW_ARRAY); - vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_TRUE; - vao->_Enabled |= VERT_BIT_GENERIC(index); - vao->NewArrays |= VERT_BIT_GENERIC(index); - } + _mesa_enable_vertex_array_attrib(ctx, vao, VERT_ATTRIB_GENERIC(index)); } @@ -1710,8 +1749,8 @@ vertex_array_vertex_buffer(struct gl_context *ctx, struct gl_vertex_array_object vbo = ctx->Shared->NullBufferObj; } - bind_vertex_buffer(ctx, vao, VERT_ATTRIB_GENERIC(bindingIndex), - vbo, offset, stride); + _mesa_bind_vertex_buffer(ctx, vao, VERT_ATTRIB_GENERIC(bindingIndex), + vbo, offset, stride); } @@ -1798,8 +1837,8 @@ vertex_array_vertex_buffers(struct gl_context *ctx, struct gl_buffer_object *vbo = ctx->Shared->NullBufferObj; for (i = 0; i < count; i++) - bind_vertex_buffer(ctx, vao, VERT_ATTRIB_GENERIC(first + i), - vbo, 0, 16); + _mesa_bind_vertex_buffer(ctx, vao, VERT_ATTRIB_GENERIC(first + i), + vbo, 0, 16); return; } @@ -1870,8 +1909,8 @@ vertex_array_vertex_buffers(struct gl_context *ctx, vbo = ctx->Shared->NullBufferObj; } - bind_vertex_buffer(ctx, vao, VERT_ATTRIB_GENERIC(first + i), - vbo, offsets[i], strides[i]); + _mesa_bind_vertex_buffer(ctx, vao, VERT_ATTRIB_GENERIC(first + i), + vbo, offsets[i], strides[i]); } _mesa_end_bufferobj_lookups(ctx); diff --git a/lib/mesa/src/mesa/main/varray.h b/lib/mesa/src/mesa/main/varray.h index 5583ed5a1..a766afad5 100644 --- a/lib/mesa/src/mesa/main/varray.h +++ b/lib/mesa/src/mesa/main/varray.h @@ -90,6 +90,26 @@ _mesa_attr_zero_aliases_vertex(struct gl_context *ctx) && !is_forward_compatible_context)); } +extern void +_mesa_update_array_format(struct gl_context *ctx, + struct gl_vertex_array_object *vao, + GLuint attrib, GLint size, GLenum type, + GLenum format, GLboolean normalized, + GLboolean integer, GLboolean doubles, + GLuint relativeOffset, bool flush_vertices); + +extern void +_mesa_enable_vertex_array_attrib(struct gl_context *ctx, + struct gl_vertex_array_object *vao, + unsigned attrib); + +extern void +_mesa_bind_vertex_buffer(struct gl_context *ctx, + struct gl_vertex_array_object *vao, + GLuint index, + struct gl_buffer_object *vbo, + GLintptr offset, GLsizei stride); + extern void GLAPIENTRY _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr); |