summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2017-06-16 11:35:32 -0700
committerJason Ekstrand <[email protected]>2017-07-12 21:15:46 -0700
commit2dd4e2348f3c05cd11cd6573fbbaeea7ab898692 (patch)
tree72be5224cd63172b14662704b35ef6d16f7d81f9 /src
parent14ce44a7bca30999601969563d97167751cdd326 (diff)
i965/miptree: Add a colorspace parameter to create_for_dri_image
The __DRI_FORMAT enums are all UNORM but we will frequently want sRGB when creating miptrees for renderbuffers. This lets us specify. Reviewed-by: Chad Versace <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/i965/intel_fbo.c3
-rw-r--r--src/mesa/drivers/dri/i965/intel_mipmap_tree.c24
-rw-r--r--src/mesa/drivers/dri/i965/intel_mipmap_tree.h3
-rw-r--r--src/mesa/drivers/dri/i965/intel_tex_image.c3
4 files changed, 28 insertions, 5 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_fbo.c b/src/mesa/drivers/dri/i965/intel_fbo.c
index 4003e288250..3670c2a0b7f 100644
--- a/src/mesa/drivers/dri/i965/intel_fbo.c
+++ b/src/mesa/drivers/dri/i965/intel_fbo.c
@@ -362,7 +362,8 @@ intel_image_target_renderbuffer_storage(struct gl_context *ctx,
* buffer's content to the main buffer nor for invalidating the aux buffer's
* content.
*/
- irb->mt = intel_miptree_create_for_dri_image(brw, image, GL_TEXTURE_2D);
+ irb->mt = intel_miptree_create_for_dri_image(brw, image, GL_TEXTURE_2D,
+ ISL_COLORSPACE_NONE);
if (!irb->mt)
return;
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index f1ac074fb50..6159fb31a25 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -1040,12 +1040,32 @@ miptree_create_for_planar_image(struct brw_context *brw,
struct intel_mipmap_tree *
intel_miptree_create_for_dri_image(struct brw_context *brw,
- __DRIimage *image, GLenum target)
+ __DRIimage *image, GLenum target,
+ enum isl_colorspace colorspace)
{
- if (image->planar_format && image->planar_format->nplanes > 0)
+ if (image->planar_format && image->planar_format->nplanes > 0) {
+ assert(colorspace == ISL_COLORSPACE_NONE ||
+ colorspace == ISL_COLORSPACE_YUV);
return miptree_create_for_planar_image(brw, image, target);
+ }
mesa_format format = image->format;
+ switch (colorspace) {
+ case ISL_COLORSPACE_NONE:
+ /* Keep the image format unmodified */
+ break;
+
+ case ISL_COLORSPACE_LINEAR:
+ format =_mesa_get_srgb_format_linear(format);
+ break;
+
+ case ISL_COLORSPACE_SRGB:
+ format =_mesa_get_linear_format_srgb(format);
+ break;
+
+ default:
+ unreachable("Inalid colorspace for non-planar image");
+ }
if (!brw->ctx.TextureFormatSupported[format]) {
/* The texture storage paths in core Mesa detect if the driver does not
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
index 4cc5c3539ff..6668d317a26 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
@@ -689,7 +689,8 @@ intel_miptree_create_for_bo(struct brw_context *brw,
struct intel_mipmap_tree *
intel_miptree_create_for_dri_image(struct brw_context *brw,
__DRIimage *image,
- GLenum target);
+ GLenum target,
+ enum isl_colorspace colorspace);
bool
intel_update_winsys_renderbuffer_miptree(struct brw_context *intel,
diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c b/src/mesa/drivers/dri/i965/intel_tex_image.c
index abeb245373b..7765d1bddf8 100644
--- a/src/mesa/drivers/dri/i965/intel_tex_image.c
+++ b/src/mesa/drivers/dri/i965/intel_tex_image.c
@@ -356,7 +356,8 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
return;
}
- mt = intel_miptree_create_for_dri_image(brw, image, target);
+ mt = intel_miptree_create_for_dri_image(brw, image, target,
+ ISL_COLORSPACE_NONE);
if (mt == NULL)
return;