summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/drivers/svga/svga_resource_texture.c20
-rw-r--r--src/gallium/drivers/svga/svga_resource_texture.h8
-rw-r--r--src/gallium/drivers/svga/svga_sampler_view.c2
-rw-r--r--src/gallium/drivers/svga/svga_screen.c4
-rw-r--r--src/gallium/drivers/svga/svga_surface.c6
5 files changed, 23 insertions, 17 deletions
diff --git a/src/gallium/drivers/svga/svga_resource_texture.c b/src/gallium/drivers/svga/svga_resource_texture.c
index 5fb31d2940b..8297f830a61 100644
--- a/src/gallium/drivers/svga/svga_resource_texture.c
+++ b/src/gallium/drivers/svga/svga_resource_texture.c
@@ -54,7 +54,8 @@
SVGA3dSurfaceFormat
svga_translate_format(struct svga_screen *ss,
- enum pipe_format format)
+ enum pipe_format format,
+ unsigned bind)
{
switch(format) {
@@ -81,11 +82,11 @@ svga_translate_format(struct svga_screen *ss,
return SVGA3D_Z_D32;
*/
case PIPE_FORMAT_Z16_UNORM:
- return ss->depth.z16;
+ return bind & PIPE_BIND_SAMPLER_VIEW ? ss->depth.z16 : SVGA3D_Z_D16;
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
- return ss->depth.s8z24;
+ return bind & PIPE_BIND_SAMPLER_VIEW ? ss->depth.s8z24 : SVGA3D_Z_D24S8;
case PIPE_FORMAT_X8Z24_UNORM:
- return ss->depth.x8z24;
+ return bind & PIPE_BIND_SAMPLER_VIEW ? ss->depth.x8z24 : SVGA3D_Z_D24X8;
case PIPE_FORMAT_A8_UNORM:
return SVGA3D_ALPHA8;
@@ -108,7 +109,8 @@ svga_translate_format(struct svga_screen *ss,
SVGA3dSurfaceFormat
svga_translate_format_render(struct svga_screen *ss,
- enum pipe_format format)
+ enum pipe_format format,
+ unsigned bind)
{
switch(format) {
case PIPE_FORMAT_B8G8R8A8_UNORM:
@@ -121,7 +123,7 @@ svga_translate_format_render(struct svga_screen *ss,
case PIPE_FORMAT_Z32_UNORM:
case PIPE_FORMAT_Z16_UNORM:
case PIPE_FORMAT_L8_UNORM:
- return svga_translate_format(ss, format);
+ return svga_translate_format(ss, format, bind);
default:
return SVGA3D_FORMAT_INVALID;
@@ -562,7 +564,7 @@ svga_texture_create(struct pipe_screen *screen,
tex->key.numMipLevels = template->last_level + 1;
- tex->key.format = svga_translate_format(svgascreen, template->format);
+ tex->key.format = svga_translate_format(svgascreen, template->format, template->bind);
if(tex->key.format == SVGA3D_FORMAT_INVALID)
goto error2;
@@ -609,8 +611,8 @@ svga_texture_from_handle(struct pipe_screen *screen,
if (!srf)
return NULL;
- if (svga_translate_format(svga_screen(screen), template->format) != format) {
- unsigned f1 = svga_translate_format(svga_screen(screen), template->format);
+ if (svga_translate_format(svga_screen(screen), template->format, template->bind) != format) {
+ unsigned f1 = svga_translate_format(svga_screen(screen), template->format, template->bind);
unsigned f2 = format;
/* It's okay for XRGB and ARGB or depth with/out stencil to get mixed up */
diff --git a/src/gallium/drivers/svga/svga_resource_texture.h b/src/gallium/drivers/svga/svga_resource_texture.h
index fac6a375495..eb85c698c98 100644
--- a/src/gallium/drivers/svga/svga_resource_texture.h
+++ b/src/gallium/drivers/svga/svga_resource_texture.h
@@ -127,10 +127,14 @@ svga_texture_from_handle(struct pipe_screen * screen,
enum SVGA3dSurfaceFormat
-svga_translate_format(struct svga_screen *ss, enum pipe_format format);
+svga_translate_format(struct svga_screen *ss,
+ enum pipe_format format,
+ unsigned bind);
enum SVGA3dSurfaceFormat
-svga_translate_format_render(struct svga_screen *ss, enum pipe_format format);
+svga_translate_format_render(struct svga_screen *ss,
+ enum pipe_format format,
+ unsigned bind);
#endif /* SVGA_TEXTURE_H */
diff --git a/src/gallium/drivers/svga/svga_sampler_view.c b/src/gallium/drivers/svga/svga_sampler_view.c
index 04aeddc7194..56acffee6d0 100644
--- a/src/gallium/drivers/svga/svga_sampler_view.c
+++ b/src/gallium/drivers/svga/svga_sampler_view.c
@@ -60,7 +60,7 @@ svga_get_tex_sampler_view(struct pipe_context *pipe,
struct svga_texture *tex = svga_texture(pt);
struct svga_sampler_view *sv = NULL;
SVGA3dSurfaceFlags flags = SVGA3D_SURFACE_HINT_TEXTURE;
- SVGA3dSurfaceFormat format = svga_translate_format(ss, pt->format);
+ SVGA3dSurfaceFormat format = svga_translate_format(ss, pt->format, PIPE_BIND_SAMPLER_VIEW);
boolean view = TRUE;
assert(pt);
diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c
index e8f17ba30b0..98479f0d84e 100644
--- a/src/gallium/drivers/svga/svga_screen.c
+++ b/src/gallium/drivers/svga/svga_screen.c
@@ -404,9 +404,9 @@ svga_is_format_supported( struct pipe_screen *screen,
* out of sync:
*/
if(tex_usage & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DEPTH_STENCIL))
- return svga_translate_format_render(ss, format) != SVGA3D_FORMAT_INVALID;
+ return svga_translate_format_render(ss, format, tex_usage) != SVGA3D_FORMAT_INVALID;
else
- return svga_translate_format(ss, format) != SVGA3D_FORMAT_INVALID;
+ return svga_translate_format(ss, format, tex_usage) != SVGA3D_FORMAT_INVALID;
}
diff --git a/src/gallium/drivers/svga/svga_surface.c b/src/gallium/drivers/svga/svga_surface.c
index 1bcbd3e002b..00973263112 100644
--- a/src/gallium/drivers/svga/svga_surface.c
+++ b/src/gallium/drivers/svga/svga_surface.c
@@ -225,7 +225,7 @@ svga_create_surface(struct pipe_context *pipe,
if (!render) {
flags = SVGA3D_SURFACE_HINT_TEXTURE;
- format = svga_translate_format(ss, surf_tmpl->format);
+ format = svga_translate_format(ss, surf_tmpl->format, surf_tmpl->usage);
} else {
if (surf_tmpl->usage & PIPE_BIND_RENDER_TARGET) {
flags = SVGA3D_SURFACE_HINT_RENDERTARGET;
@@ -233,7 +233,7 @@ svga_create_surface(struct pipe_context *pipe,
if (surf_tmpl->usage & PIPE_BIND_DEPTH_STENCIL) {
flags = SVGA3D_SURFACE_HINT_DEPTHSTENCIL;
}
- format = svga_translate_format_render(ss, surf_tmpl->format);
+ format = svga_translate_format_render(ss, surf_tmpl->format, surf_tmpl->usage);
}
assert(format != SVGA3D_FORMAT_INVALID);
@@ -243,7 +243,7 @@ svga_create_surface(struct pipe_context *pipe,
/* Currently only used for compressed textures */
if (render &&
- format != svga_translate_format(ss, surf_tmpl->format)) {
+ format != svga_translate_format(ss, surf_tmpl->format, surf_tmpl->usage)) {
view = TRUE;
}