diff options
Diffstat (limited to 'mesalib/src')
-rw-r--r-- | mesalib/src/glsl/README | 16 | ||||
-rw-r--r-- | mesalib/src/mesa/drivers/common/meta_blit.c | 1 | ||||
-rw-r--r-- | mesalib/src/mesa/main/bufferobj.c | 21 | ||||
-rw-r--r-- | mesalib/src/mesa/main/bufferobj.h | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/main/dd.h | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/main/mtypes.h | 13 | ||||
-rw-r--r-- | mesalib/src/mesa/main/shared.c | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/main/teximage.c | 6 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c | 4 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_eglimage.c | 3 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_texture.c | 13 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_gen_mipmap.c | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_texture.c | 6 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_texture.h | 3 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_vdpau.c | 4 | ||||
-rw-r--r-- | mesalib/src/mesa/vbo/vbo_exec_api.c | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/vbo/vbo_save_api.c | 4 |
17 files changed, 66 insertions, 38 deletions
diff --git a/mesalib/src/glsl/README b/mesalib/src/glsl/README index 0a0afccdc..2f93f12ff 100644 --- a/mesalib/src/glsl/README +++ b/mesalib/src/glsl/README @@ -8,7 +8,7 @@ passed straight through. See glcpp/* 2) lex and yacc-based parser takes the preprocessed string and generates the AST (abstract syntax tree). Almost no checking is -performed in this stage. See glsl_lexer.lpp and glsl_parser.ypp. +performed in this stage. See glsl_lexer.ll and glsl_parser.yy. 3) The AST is converted to "HIR". This is the intermediate representation of the compiler. Constructors are generated, function @@ -34,7 +34,7 @@ linked in. 7) The driver performs code generation out of the IR, taking a linked shader program and producing a compiled program for each stage. See -ir_to_mesa.cpp for Mesa IR code generation. +../mesa/program/ir_to_mesa.cpp for Mesa IR code generation. FAQ: @@ -126,7 +126,7 @@ optimizations like CSE where one must navigate an expression tree. Q: Why no SSA representation? -A: Converting an IR tree to SSA form makes dead code elmimination, +A: Converting an IR tree to SSA form makes dead code elimination, common subexpression elimination, and many other optimizations much easier. However, in our primarily vector-based language, there's some major questions as to how it would work. Do we do SSA on the scalar @@ -134,9 +134,9 @@ or vector level? If we do it at the vector level, we're going to end up with many different versions of the variable when encountering code like: -(assign (constant bool (1)) (swiz x (var_ref __retval) ) (var_ref a) ) -(assign (constant bool (1)) (swiz y (var_ref __retval) ) (var_ref b) ) -(assign (constant bool (1)) (swiz z (var_ref __retval) ) (var_ref c) ) +(assign (constant bool (1)) (swiz x (var_ref __retval) ) (var_ref a) ) +(assign (constant bool (1)) (swiz y (var_ref __retval) ) (var_ref b) ) +(assign (constant bool (1)) (swiz z (var_ref __retval) ) (var_ref c) ) If every masked update of a component relies on the previous value of the variable, then we're probably going to be quite limited in our @@ -183,7 +183,7 @@ ir_validate.cpp (check users have the right types) You may also need to update the backends if they will see the new expr type: -../mesa/shaders/ir_to_mesa.cpp +../mesa/program/ir_to_mesa.cpp You can then use the new expression from builtins (if all backends would rather see it), or scan the IR and convert to use your new @@ -225,4 +225,4 @@ Initially, there really wasn't one. We have since adopted one: - Files that implement a class that is used throught the code should take the name of that class (e.g., ir_hierarchical_visitor.cpp). - Files that contain code not fitting in one of the previous - categories should have a sensible name (e.g., glsl_parser.ypp). + categories should have a sensible name (e.g., glsl_parser.yy). diff --git a/mesalib/src/mesa/drivers/common/meta_blit.c b/mesalib/src/mesa/drivers/common/meta_blit.c index c6616d93d..01cb532fe 100644 --- a/mesalib/src/mesa/drivers/common/meta_blit.c +++ b/mesalib/src/mesa/drivers/common/meta_blit.c @@ -134,6 +134,7 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx, break; default: _mesa_problem(ctx, "Unsupported sample count %d\n", samples); + unreachable("Unsupported sample count"); } /* Create sample map string. */ diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c index b6879ceb5..0ee88560f 100644 --- a/mesalib/src/mesa/main/bufferobj.c +++ b/mesalib/src/mesa/main/bufferobj.c @@ -389,14 +389,14 @@ convert_clear_buffer_data(struct gl_context *ctx, * Default callback for the \c dd_function_table::NewBufferObject() hook. */ static struct gl_buffer_object * -_mesa_new_buffer_object( struct gl_context *ctx, GLuint name, GLenum target ) +_mesa_new_buffer_object(struct gl_context *ctx, GLuint name) { struct gl_buffer_object *obj; (void) ctx; obj = MALLOC_STRUCT(gl_buffer_object); - _mesa_initialize_buffer_object(ctx, obj, name, target); + _mesa_initialize_buffer_object(ctx, obj, name); return obj; } @@ -494,12 +494,10 @@ _mesa_reference_buffer_object_(struct gl_context *ctx, * Initialize a buffer object to default values. */ void -_mesa_initialize_buffer_object( struct gl_context *ctx, - struct gl_buffer_object *obj, - GLuint name, GLenum target ) +_mesa_initialize_buffer_object(struct gl_context *ctx, + struct gl_buffer_object *obj, + GLuint name) { - (void) target; - memset(obj, 0, sizeof(struct gl_buffer_object)); mtx_init(&obj->Mutex, mtx_plain); obj->RefCount = 1; @@ -906,7 +904,7 @@ _mesa_handle_bind_buffer_gen(struct gl_context *ctx, * never used before, allocate a buffer object now. */ ASSERT(ctx->Driver.NewBufferObject); - buf = ctx->Driver.NewBufferObject(ctx, buffer, target); + buf = ctx->Driver.NewBufferObject(ctx, buffer); if (!buf) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", caller); return false; @@ -2652,6 +2650,12 @@ set_ubo_binding(struct gl_context *ctx, binding->Offset = offset; binding->Size = size; binding->AutomaticSize = autoSize; + + /* If this is a real buffer object, mark it has having been used + * at some point as a UBO. + */ + if (size >= 0) + bufObj->UsageHistory |= USAGE_UNIFORM_BUFFER; } /** @@ -2764,6 +2768,7 @@ set_atomic_buffer_binding(struct gl_context *ctx, } else { binding->Offset = offset; binding->Size = size; + bufObj->UsageHistory |= USAGE_ATOMIC_COUNTER_BUFFER; } } diff --git a/mesalib/src/mesa/main/bufferobj.h b/mesalib/src/mesa/main/bufferobj.h index 0779605c0..fe294fc0b 100644 --- a/mesalib/src/mesa/main/bufferobj.h +++ b/mesalib/src/mesa/main/bufferobj.h @@ -103,7 +103,7 @@ _mesa_multi_bind_lookup_bufferobj(struct gl_context *ctx, extern void _mesa_initialize_buffer_object(struct gl_context *ctx, struct gl_buffer_object *obj, - GLuint name, GLenum target); + GLuint name); extern void _mesa_reference_buffer_object_(struct gl_context *ctx, diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h index c130b14a5..c07e83ad9 100644 --- a/mesalib/src/mesa/main/dd.h +++ b/mesalib/src/mesa/main/dd.h @@ -602,7 +602,7 @@ struct dd_function_table { */ /*@{*/ struct gl_buffer_object * (*NewBufferObject)(struct gl_context *ctx, - GLuint buffer, GLenum target); + GLuint buffer); void (*DeleteBuffer)( struct gl_context *ctx, struct gl_buffer_object *obj ); diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index 5e9453b2f..9f44edac6 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -1465,6 +1465,16 @@ struct gl_buffer_mapping { /** + * Usages we've seen for a buffer object. + */ +typedef enum { + USAGE_UNIFORM_BUFFER = 0x1, + USAGE_TEXTURE_BUFFER = 0x2, + USAGE_ATOMIC_COUNTER_BUFFER = 0x4, +} gl_buffer_usage; + + +/** * GL_ARB_vertex/pixel_buffer_object buffer object */ struct gl_buffer_object @@ -1481,6 +1491,7 @@ struct gl_buffer_object GLboolean Written; /**< Ever written to? (for debugging) */ GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ GLboolean Immutable; /**< GL_ARB_buffer_storage */ + gl_buffer_usage UsageHistory; /**< How has this buffer been used so far? */ struct gl_buffer_mapping Mappings[MAP_COUNT]; }; @@ -4060,6 +4071,8 @@ struct gl_driver_flags */ uint64_t NewUniformBuffer; + uint64_t NewTextureBuffer; + /** * gl_context::AtomicBufferBindings */ diff --git a/mesalib/src/mesa/main/shared.c b/mesalib/src/mesa/main/shared.c index 7ef932ff0..f74a8232f 100644 --- a/mesalib/src/mesa/main/shared.c +++ b/mesalib/src/mesa/main/shared.c @@ -86,7 +86,7 @@ _mesa_alloc_shared_state(struct gl_context *ctx) shared->SamplerObjects = _mesa_NewHashTable(); /* Allocate the default buffer object */ - shared->NullBufferObj = ctx->Driver.NewBufferObject(ctx, 0, 0); + shared->NullBufferObj = ctx->Driver.NewBufferObject(ctx, 0); /* Create default texture objects */ for (i = 0; i < NUM_TEXTURE_TARGETS; i++) { diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c index c0298af8e..4f4bb11dd 100644 --- a/mesalib/src/mesa/main/teximage.c +++ b/mesalib/src/mesa/main/teximage.c @@ -4652,6 +4652,12 @@ texbufferrange(struct gl_context *ctx, GLenum target, GLenum internalFormat, texObj->BufferSize = size; } _mesa_unlock_texture(ctx, texObj); + + ctx->NewDriverState |= ctx->DriverFlags.NewTextureBuffer; + + if (bufObj) { + bufObj->UsageHistory |= USAGE_TEXTURE_BUFFER; + } } diff --git a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c index d53602c8b..55f36442a 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -54,14 +54,14 @@ * internal structure where somehow shared. */ static struct gl_buffer_object * -st_bufferobj_alloc(struct gl_context *ctx, GLuint name, GLenum target) +st_bufferobj_alloc(struct gl_context *ctx, GLuint name) { struct st_buffer_object *st_obj = ST_CALLOC_STRUCT(st_buffer_object); if (!st_obj) return NULL; - _mesa_initialize_buffer_object(ctx, &st_obj->Base, name, target); + _mesa_initialize_buffer_object(ctx, &st_obj->Base, name); return &st_obj->Base; } diff --git a/mesalib/src/mesa/state_tracker/st_cb_eglimage.c b/mesalib/src/mesa/state_tracker/st_cb_eglimage.c index 34eb80959..8531afb29 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_eglimage.c +++ b/mesalib/src/mesa/state_tracker/st_cb_eglimage.c @@ -96,6 +96,7 @@ st_bind_surface(struct gl_context *ctx, GLenum target, struct gl_texture_image *texImage, struct pipe_surface *ps) { + struct st_context *st = st_context(ctx); struct st_texture_object *stObj; struct st_texture_image *stImage; GLenum internalFormat; @@ -124,7 +125,7 @@ st_bind_surface(struct gl_context *ctx, GLenum target, /* FIXME create a non-default sampler view from the pipe_surface? */ pipe_resource_reference(&stObj->pt, ps->texture); - st_texture_release_all_sampler_views(stObj); + st_texture_release_all_sampler_views(st, stObj); pipe_resource_reference(&stImage->pt, stObj->pt); stObj->width0 = ps->width; diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c index dfa188a3f..a8dbb7888 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_texture.c +++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c @@ -152,10 +152,11 @@ static void st_DeleteTextureObject(struct gl_context *ctx, struct gl_texture_object *texObj) { + struct st_context *st = st_context(ctx); struct st_texture_object *stObj = st_texture_object(texObj); pipe_resource_reference(&stObj->pt, NULL); - st_texture_release_all_sampler_views(stObj); + st_texture_release_all_sampler_views(st, stObj); st_texture_free_sampler_views(stObj); _mesa_delete_texture_object(ctx, texObj); } @@ -512,7 +513,7 @@ st_AllocTextureImageBuffer(struct gl_context *ctx, /* The parent texture object does not have space for this image */ pipe_resource_reference(&stObj->pt, NULL); - st_texture_release_all_sampler_views(stObj); + st_texture_release_all_sampler_views(st, stObj); if (!guess_and_alloc_texture(st, stObj, stImage)) { /* Probably out of memory. @@ -1571,13 +1572,13 @@ st_finalize_texture(struct gl_context *ctx, if (!st_obj) { pipe_resource_reference(&stObj->pt, NULL); - st_texture_release_all_sampler_views(stObj); + st_texture_release_all_sampler_views(st, stObj); return GL_TRUE; } if (st_obj->buffer != stObj->pt) { pipe_resource_reference(&stObj->pt, st_obj->buffer); - st_texture_release_all_sampler_views(stObj); + st_texture_release_all_sampler_views(st, stObj); stObj->width0 = stObj->pt->width0 / _mesa_get_format_bytes(tObj->_BufferObjectFormat); stObj->height0 = 1; stObj->depth0 = 1; @@ -1598,7 +1599,7 @@ st_finalize_texture(struct gl_context *ctx, firstImage->pt != stObj->pt && (!stObj->pt || firstImage->pt->last_level >= stObj->pt->last_level)) { pipe_resource_reference(&stObj->pt, firstImage->pt); - st_texture_release_all_sampler_views(stObj); + st_texture_release_all_sampler_views(st, stObj); } /* If this texture comes from a window system, there is nothing else to do. */ @@ -1646,7 +1647,7 @@ st_finalize_texture(struct gl_context *ctx, * gallium texture now. We'll make a new one below. */ pipe_resource_reference(&stObj->pt, NULL); - st_texture_release_all_sampler_views(stObj); + st_texture_release_all_sampler_views(st, stObj); st->dirty.st |= ST_NEW_FRAMEBUFFER; } } diff --git a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c index 18cf504a7..26e1c21f6 100644 --- a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c +++ b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c @@ -124,7 +124,7 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target, /* release the old tex (will likely be freed too) */ pipe_resource_reference(&oldTex, NULL); - st_texture_release_all_sampler_views(stObj); + st_texture_release_all_sampler_views(st, stObj); } else { /* Make sure that the base texture image data is present in the diff --git a/mesalib/src/mesa/state_tracker/st_texture.c b/mesalib/src/mesa/state_tracker/st_texture.c index 5996b7d1b..ada984189 100644 --- a/mesalib/src/mesa/state_tracker/st_texture.c +++ b/mesalib/src/mesa/state_tracker/st_texture.c @@ -519,12 +519,14 @@ st_texture_release_sampler_view(struct st_context *st, } void -st_texture_release_all_sampler_views(struct st_texture_object *stObj) +st_texture_release_all_sampler_views(struct st_context *st, + struct st_texture_object *stObj) { GLuint i; + /* XXX This should use sampler_views[i]->pipe, not st->pipe */ for (i = 0; i < stObj->num_sampler_views; ++i) - pipe_sampler_view_reference(&stObj->sampler_views[i], NULL); + pipe_sampler_view_release(st->pipe, &stObj->sampler_views[i]); } diff --git a/mesalib/src/mesa/state_tracker/st_texture.h b/mesalib/src/mesa/state_tracker/st_texture.h index ce1cf8b0a..d66afcb56 100644 --- a/mesalib/src/mesa/state_tracker/st_texture.h +++ b/mesalib/src/mesa/state_tracker/st_texture.h @@ -255,7 +255,8 @@ st_texture_release_sampler_view(struct st_context *st, struct st_texture_object *stObj); extern void -st_texture_release_all_sampler_views(struct st_texture_object *stObj); +st_texture_release_all_sampler_views(struct st_context *st, + struct st_texture_object *stObj); void st_texture_free_sampler_views(struct st_texture_object *stObj); diff --git a/mesalib/src/mesa/state_tracker/st_vdpau.c b/mesalib/src/mesa/state_tracker/st_vdpau.c index 8c10cdaf3..6ccaf3e3f 100644 --- a/mesalib/src/mesa/state_tracker/st_vdpau.c +++ b/mesalib/src/mesa/state_tracker/st_vdpau.c @@ -139,7 +139,7 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access, texFormat); pipe_resource_reference(&stObj->pt, res); - st_texture_release_all_sampler_views(stObj); + st_texture_release_all_sampler_views(st, stObj); pipe_resource_reference(&stImage->pt, res); u_sampler_view_default_template(&templ, res, res->format); @@ -172,7 +172,7 @@ st_vdpau_unmap_surface(struct gl_context *ctx, GLenum target, GLenum access, struct st_texture_image *stImage = st_texture_image(texImage); pipe_resource_reference(&stObj->pt, NULL); - st_texture_release_all_sampler_views(stObj); + st_texture_release_all_sampler_views(st, stObj); pipe_resource_reference(&stImage->pt, NULL); _mesa_dirty_texobj(ctx, texObj); diff --git a/mesalib/src/mesa/vbo/vbo_exec_api.c b/mesalib/src/mesa/vbo/vbo_exec_api.c index 2871100ae..5f8250e78 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_api.c +++ b/mesalib/src/mesa/vbo/vbo_exec_api.c @@ -997,7 +997,7 @@ void vbo_use_buffer_objects(struct gl_context *ctx) /* Allocate a real buffer object now */ _mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL); - exec->vtx.bufferobj = ctx->Driver.NewBufferObject(ctx, bufName, target); + exec->vtx.bufferobj = ctx->Driver.NewBufferObject(ctx, bufName); if (!ctx->Driver.BufferData(ctx, target, size, NULL, usage, GL_MAP_WRITE_BIT | GL_DYNAMIC_STORAGE_BIT | diff --git a/mesalib/src/mesa/vbo/vbo_save_api.c b/mesalib/src/mesa/vbo/vbo_save_api.c index 1c6b91942..848eedaa4 100644 --- a/mesalib/src/mesa/vbo/vbo_save_api.c +++ b/mesalib/src/mesa/vbo/vbo_save_api.c @@ -191,9 +191,7 @@ alloc_vertex_store(struct gl_context *ctx) * user. Perhaps there could be a special number for internal * buffers: */ - vertex_store->bufferobj = ctx->Driver.NewBufferObject(ctx, - VBO_BUF_ID, - GL_ARRAY_BUFFER_ARB); + vertex_store->bufferobj = ctx->Driver.NewBufferObject(ctx, VBO_BUF_ID); if (vertex_store->bufferobj) { save->out_of_memory = !ctx->Driver.BufferData(ctx, |