summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2015-01-07 21:13:49 -0800
committerJason Ekstrand <jason.ekstrand@intel.com>2015-01-22 10:21:07 -0800
commit333226522cd9ae541147b52e20f577aa19c50426 (patch)
tree6010a871078e040400d0055f7029d72364a53454 /src/mesa/drivers/dri
parent117a1d69de84c6cb7d895ce7e157f434facde7c9 (diff)
downloadexternal_mesa3d-333226522cd9ae541147b52e20f577aa19c50426.zip
external_mesa3d-333226522cd9ae541147b52e20f577aa19c50426.tar.gz
external_mesa3d-333226522cd9ae541147b52e20f577aa19c50426.tar.bz2
i965: Implement SetTextureStorageForBufferObject
Reviewed-by: Neil Roberts <neil@linux.intel.com>
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r--src/mesa/drivers/dri/i965/intel_tex.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_tex.c b/src/mesa/drivers/dri/i965/intel_tex.c
index b2c0335..184702f 100644
--- a/src/mesa/drivers/dri/i965/intel_tex.c
+++ b/src/mesa/drivers/dri/i965/intel_tex.c
@@ -5,6 +5,7 @@
#include "main/mipmap.h"
#include "drivers/common/meta.h"
#include "brw_context.h"
+#include "intel_buffer_objects.h"
#include "intel_mipmap_tree.h"
#include "intel_tex.h"
#include "intel_fbo.h"
@@ -298,6 +299,60 @@ intel_texture_view(struct gl_context *ctx,
return GL_TRUE;
}
+static bool
+intel_set_texture_storage_for_buffer_object(struct gl_context *ctx,
+ struct gl_texture_object *tex_obj,
+ struct gl_buffer_object *buffer_obj,
+ uint32_t buffer_offset,
+ uint32_t row_stride,
+ bool read_only)
+{
+ struct brw_context *brw = brw_context(ctx);
+ struct intel_texture_object *intel_texobj = intel_texture_object(tex_obj);
+ struct gl_texture_image *image = tex_obj->Image[0][0];
+ struct intel_texture_image *intel_image = intel_texture_image(image);
+ struct intel_buffer_object *intel_buffer_obj = intel_buffer_object(buffer_obj);
+
+ if (!read_only) {
+ /* Renderbuffers have the restriction that the buffer offset and
+ * surface pitch must be a multiple of the element size. If it's
+ * not, we have to fail and fall back to software.
+ */
+ int cpp = _mesa_get_format_bytes(image->TexFormat);
+ if (buffer_offset % cpp || row_stride % cpp) {
+ perf_debug("Bad PBO alignment; fallback to CPU mapping\n");
+ return false;
+ }
+ }
+
+ assert(intel_texobj->mt == NULL);
+
+ drm_intel_bo *bo = intel_bufferobj_buffer(brw, intel_buffer_obj,
+ buffer_offset,
+ row_stride * image->Height);
+ intel_texobj->mt =
+ intel_miptree_create_for_bo(brw, bo,
+ image->TexFormat,
+ buffer_offset,
+ image->Width, image->Height, image->Depth,
+ row_stride);
+ if (!intel_texobj->mt)
+ return false;
+
+ if (!_swrast_init_texture_image(image))
+ return false;
+
+ intel_miptree_reference(&intel_image->mt, intel_texobj->mt);
+
+ /* The miptree is in a validated state, so no need to check later. */
+ intel_texobj->needs_validate = false;
+ intel_texobj->validated_first_level = 0;
+ intel_texobj->validated_last_level = 0;
+ intel_texobj->_Format = intel_texobj->mt->format;
+
+ return true;
+}
+
void
intelInitTextureFuncs(struct dd_function_table *functions)
{
@@ -311,4 +366,6 @@ intelInitTextureFuncs(struct dd_function_table *functions)
functions->MapTextureImage = intel_map_texture_image;
functions->UnmapTextureImage = intel_unmap_texture_image;
functions->TextureView = intel_texture_view;
+ functions->SetTextureStorageForBufferObject =
+ intel_set_texture_storage_for_buffer_object;
}