[Mesa-dev] [PATCH 6/9] i965: Add support for GL_ARB_texture_buffer_range.
Eric Anholt
eric at anholt.net
Tue Oct 8 14:00:33 PDT 2013
Supporting this extension turns out to simplify our code a bit over not
supporting this extension, once the glBufferSubData() synchronization code
lands.
---
docs/GL3.txt | 2 +-
src/mesa/drivers/dri/i965/brw_context.c | 1 +
src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 15 +++++++++++----
src/mesa/drivers/dri/i965/gen7_wm_surface_state.c | 14 ++++++++++----
src/mesa/drivers/dri/i965/intel_extensions.c | 1 +
5 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/docs/GL3.txt b/docs/GL3.txt
index c269f19..1b04cc1 100644
--- a/docs/GL3.txt
+++ b/docs/GL3.txt
@@ -157,7 +157,7 @@ ARB_robust_buffer_access_behavior not started
ARB_shader_image_size not started
ARB_shader_storage_buffer_object not started
ARB_stencil_texturing not started
-ARB_texture_buffer_range DONE (nv50, nvc0)
+ARB_texture_buffer_range DONE (nv50, nvc0, i965)
ARB_texture_query_levels DONE (i965)
ARB_texture_storage_multisample DONE (i965)
ARB_texture_view not started
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index dee8032..e2bf913 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -249,6 +249,7 @@ brw_initialize_context_constants(struct brw_context *brw)
* the element in the buffer."
*/
ctx->Const.UniformBufferOffsetAlignment = 1;
+ ctx->Const.TextureBufferOffsetAlignment = 1;
ctx->Const.ForceGLSLExtensionsWarn =
driQueryOptionb(&brw->optionCache, "force_glsl_extensions_warn");
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index faebc3c..f0f24f8 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -232,20 +232,27 @@ brw_update_buffer_texture_surface(struct gl_context *ctx,
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
struct intel_buffer_object *intel_obj =
intel_buffer_object(tObj->BufferObject);
- drm_intel_bo *bo = intel_obj ? intel_obj->buffer : NULL;
+ uint32_t size = tObj->BufferSize;
+ drm_intel_bo *bo = NULL;
gl_format format = tObj->_BufferObjectFormat;
uint32_t brw_format = brw_format_for_mesa_format(format);
int texel_size = _mesa_get_format_bytes(format);
- int w = intel_obj ? intel_obj->Base.Size / texel_size : 0;
+
+ if (intel_obj) {
+ bo = intel_obj->buffer;
+ size = MIN2(size, intel_obj->Base.Size);
+ }
if (brw_format == 0 && format != MESA_FORMAT_RGBA_FLOAT32) {
_mesa_problem(NULL, "bad format %s for texture buffer\n",
_mesa_get_format_name(format));
}
- gen4_emit_buffer_surface_state(brw, surf_offset, bo, 0,
+ gen4_emit_buffer_surface_state(brw, surf_offset, bo,
+ tObj->BufferOffset,
brw_format,
- w, texel_size);
+ size / texel_size,
+ texel_size);
}
static void
diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
index 564ac76..c18593a 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
@@ -274,7 +274,14 @@ gen7_update_buffer_texture_surface(struct gl_context *ctx,
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
struct intel_buffer_object *intel_obj =
intel_buffer_object(tObj->BufferObject);
- drm_intel_bo *bo = intel_obj ? intel_obj->buffer : NULL;
+ uint32_t size = tObj->BufferSize;
+ drm_intel_bo *bo = NULL;
+
+ if (intel_obj) {
+ bo = intel_obj->buffer;
+ size = MIN2(size, intel_obj->Base.Size);
+ }
+
gl_format format = tObj->_BufferObjectFormat;
uint32_t surface_format = brw_format_for_mesa_format(format);
@@ -284,14 +291,13 @@ gen7_update_buffer_texture_surface(struct gl_context *ctx,
}
int texel_size = _mesa_get_format_bytes(format);
- int w = intel_obj ? intel_obj->Base.Size / texel_size : 0;
gen7_emit_buffer_surface_state(brw,
surf_offset,
bo,
- 0,
+ tObj->BufferOffset,
surface_format,
- w,
+ size / texel_size,
texel_size,
0 /* mocs */);
}
diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c b/src/mesa/drivers/dri/i965/intel_extensions.c
index 6f024b4..272d8e3 100644
--- a/src/mesa/drivers/dri/i965/intel_extensions.c
+++ b/src/mesa/drivers/dri/i965/intel_extensions.c
@@ -144,6 +144,7 @@ intelInitExtensions(struct gl_context *ctx)
ctx->Extensions.ARB_shading_language_420pack = true;
ctx->Extensions.ARB_texture_buffer_object = true;
ctx->Extensions.ARB_texture_buffer_object_rgb32 = true;
+ ctx->Extensions.ARB_texture_buffer_range = true;
ctx->Extensions.ARB_texture_cube_map_array = true;
ctx->Extensions.OES_depth_texture_cube_map = true;
ctx->Extensions.ARB_shading_language_packing = true;
--
1.8.4.rc3
More information about the mesa-dev
mailing list