diff options
author | Dave Airlie <[email protected]> | 2012-12-06 16:12:11 +1000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2012-12-08 13:32:33 +1000 |
commit | 915efe7f07a370827be9872fbf93cf9fc304ba24 (patch) | |
tree | 17440b9197866baab2a5c1ebf5fb5372373d4677 /src/mesa/state_tracker | |
parent | a0281c4a8c056d0873a18ec790563362f37f0e74 (diff) |
st/mesa: add texture buffer object support to state tracker (v1.1)
This adds the necessary changes to the st to allow texture buffer object
support if the driver advertises it.
v1.1: remove extra blank line and whitespace
Reviewed-by: Brian Paul <[email protected]>
Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_atom_texture.c | 18 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_texture.c | 15 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_extensions.c | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_mesa_to_tgsi.c | 1 |
5 files changed, 31 insertions, 7 deletions
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c index df05e83c2d4..dba1d829c20 100644 --- a/src/mesa/state_tracker/st_atom_texture.c +++ b/src/mesa/state_tracker/st_atom_texture.c @@ -215,13 +215,19 @@ update_single_texture(struct st_context *st, /* Determine the format of the texture sampler view */ st_view_format = stObj->pt->format; - { - const struct st_texture_image *firstImage = - st_texture_image(stObj->base.Image[0][stObj->base.BaseLevel]); - const gl_format texFormat = firstImage->base.TexFormat; - enum pipe_format firstImageFormat = - st_mesa_format_to_pipe_format(texFormat); + { + gl_format texFormat; + enum pipe_format firstImageFormat; + + if (texObj->Target == GL_TEXTURE_BUFFER) { + texFormat = stObj->base._BufferObjectFormat; + } else { + const struct st_texture_image *firstImage = + st_texture_image(stObj->base.Image[0][stObj->base.BaseLevel]); + texFormat = firstImage->base.TexFormat; + } + firstImageFormat = st_mesa_format_to_pipe_format(texFormat); if ((samp->sRGBDecode == GL_SKIP_DECODE_EXT) && (_mesa_get_format_color_encoding(texFormat) == GL_SRGB)) { /* Don't do sRGB->RGB conversion. Interpret the texture data as diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 10db5bcb51a..ae069eb2cba 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -48,6 +48,7 @@ #include "state_tracker/st_cb_fbo.h" #include "state_tracker/st_cb_flush.h" #include "state_tracker/st_cb_texture.h" +#include "state_tracker/st_cb_bufferobjects.h" #include "state_tracker/st_format.h" #include "state_tracker/st_texture.h" #include "state_tracker/st_gen_mipmap.h" @@ -1229,6 +1230,20 @@ st_finalize_texture(struct gl_context *ctx, stObj->lastLevel = stObj->base._MaxLevel; } + if (tObj->Target == GL_TEXTURE_BUFFER) { + struct st_buffer_object *st_obj = st_buffer_object(tObj->BufferObject); + + if (st_obj->buffer != stObj->pt) { + pipe_resource_reference(&stObj->pt, st_obj->buffer); + pipe_sampler_view_release(st->pipe, &stObj->sampler_view); + stObj->width0 = stObj->pt->width0 / _mesa_get_format_bytes(tObj->_BufferObjectFormat); + stObj->height0 = 1; + stObj->depth0 = 1; + } + return GL_TRUE; + + } + firstImage = st_texture_image(stObj->base.Image[0][stObj->base.BaseLevel]); assert(firstImage); diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 62a736bb61b..0c6179577c6 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -643,4 +643,6 @@ void st_init_extensions(struct st_context *st) if (ctx->Const.MinMapBufferAlignment >= 64) { ctx->Extensions.ARB_map_buffer_alignment = GL_TRUE; } + if (screen->get_param(screen, PIPE_CAP_TEXTURE_BUFFER_OBJECTS)) + ctx->Extensions.ARB_texture_buffer_object = GL_TRUE; } diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index c030a6b372e..ae3b8b2c0d1 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -2776,7 +2776,7 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir) inst->tex_target = TEXTURE_RECT_INDEX; break; case GLSL_SAMPLER_DIM_BUF: - assert(!"FINISHME: Implement ARB_texture_buffer_object"); + inst->tex_target = TEXTURE_BUFFER_INDEX; break; case GLSL_SAMPLER_DIM_EXTERNAL: inst->tex_target = TEXTURE_EXTERNAL_INDEX; diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 81a870f8685..e326bcc7031 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -269,6 +269,7 @@ st_translate_texture_target( GLuint textarget, } switch( textarget ) { + case TEXTURE_BUFFER_INDEX: return TGSI_TEXTURE_BUFFER; case TEXTURE_1D_INDEX: return TGSI_TEXTURE_1D; case TEXTURE_2D_INDEX: return TGSI_TEXTURE_2D; case TEXTURE_3D_INDEX: return TGSI_TEXTURE_3D; |