summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorJakob Bornecrantz <[email protected]>2011-04-07 18:46:09 +0100
committerBrian Paul <[email protected]>2011-09-23 07:58:45 -0600
commit4e0ae3e34f50d1f66a04337b563da22250c8b8d2 (patch)
tree7e74cfb2cedd929246bf6bbbf5c95992c73edac7 /src/gallium
parentfd69fc87444af8ead30b4af64598a98df7969397 (diff)
svga: Expose the new depth formats
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/svga/svga_resource_texture.c20
-rw-r--r--src/gallium/drivers/svga/svga_resource_texture.h4
-rw-r--r--src/gallium/drivers/svga/svga_sampler_view.c2
-rw-r--r--src/gallium/drivers/svga/svga_screen.c49
-rw-r--r--src/gallium/drivers/svga/svga_screen.h8
-rw-r--r--src/gallium/drivers/svga/svga_surface.c7
6 files changed, 65 insertions, 25 deletions
diff --git a/src/gallium/drivers/svga/svga_resource_texture.c b/src/gallium/drivers/svga/svga_resource_texture.c
index f9eb4949b2c..b5497dd6a66 100644
--- a/src/gallium/drivers/svga/svga_resource_texture.c
+++ b/src/gallium/drivers/svga/svga_resource_texture.c
@@ -53,7 +53,8 @@
*/
SVGA3dSurfaceFormat
-svga_translate_format(enum pipe_format format)
+svga_translate_format(struct svga_screen *ss,
+ enum pipe_format format)
{
switch(format) {
@@ -80,11 +81,11 @@ svga_translate_format(enum pipe_format format)
return SVGA3D_Z_D32;
*/
case PIPE_FORMAT_Z16_UNORM:
- return SVGA3D_Z_D16;
+ return ss->depth.z16;
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
- return SVGA3D_Z_D24S8;
+ return ss->depth.s8z24;
case PIPE_FORMAT_X8Z24_UNORM:
- return SVGA3D_Z_D24X8;
+ return ss->depth.x8z24;
case PIPE_FORMAT_A8_UNORM:
return SVGA3D_ALPHA8;
@@ -106,7 +107,8 @@ svga_translate_format(enum pipe_format format)
SVGA3dSurfaceFormat
-svga_translate_format_render(enum pipe_format format)
+svga_translate_format_render(struct svga_screen *ss,
+ enum pipe_format format)
{
switch(format) {
case PIPE_FORMAT_B8G8R8A8_UNORM:
@@ -119,7 +121,7 @@ svga_translate_format_render(enum pipe_format format)
case PIPE_FORMAT_Z32_UNORM:
case PIPE_FORMAT_Z16_UNORM:
case PIPE_FORMAT_L8_UNORM:
- return svga_translate_format(format);
+ return svga_translate_format(ss, format);
default:
return SVGA3D_FORMAT_INVALID;
@@ -560,7 +562,7 @@ svga_texture_create(struct pipe_screen *screen,
tex->key.numMipLevels = template->last_level + 1;
- tex->key.format = svga_translate_format(template->format);
+ tex->key.format = svga_translate_format(svgascreen, template->format);
if(tex->key.format == SVGA3D_FORMAT_INVALID)
goto error2;
@@ -607,8 +609,8 @@ svga_texture_from_handle(struct pipe_screen *screen,
if (!srf)
return NULL;
- if (svga_translate_format(template->format) != format) {
- unsigned f1 = svga_translate_format(template->format);
+ if (svga_translate_format(svga_screen(screen), template->format) != format) {
+ unsigned f1 = svga_translate_format(svga_screen(screen), template->format);
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 9a2911c2a95..fac6a375495 100644
--- a/src/gallium/drivers/svga/svga_resource_texture.h
+++ b/src/gallium/drivers/svga/svga_resource_texture.h
@@ -127,10 +127,10 @@ svga_texture_from_handle(struct pipe_screen * screen,
enum SVGA3dSurfaceFormat
-svga_translate_format(enum pipe_format format);
+svga_translate_format(struct svga_screen *ss, enum pipe_format format);
enum SVGA3dSurfaceFormat
-svga_translate_format_render(enum pipe_format format);
+svga_translate_format_render(struct svga_screen *ss, enum pipe_format format);
#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 4f1f4b597e8..04aeddc7194 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(pt->format);
+ SVGA3dSurfaceFormat format = svga_translate_format(ss, pt->format);
boolean view = TRUE;
assert(pt);
diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c
index 4a60f635825..5b759627f73 100644
--- a/src/gallium/drivers/svga/svga_screen.c
+++ b/src/gallium/drivers/svga/svga_screen.c
@@ -326,13 +326,6 @@ svga_translate_format_cap(enum pipe_format format)
case PIPE_FORMAT_B4G4R4A4_UNORM:
return SVGA3D_DEVCAP_SURFACEFMT_A4R4G4B4;
- case PIPE_FORMAT_Z16_UNORM:
- return SVGA3D_DEVCAP_SURFACEFMT_Z_D16;
- case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
- return SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8;
- case PIPE_FORMAT_X8Z24_UNORM:
- return SVGA3D_DEVCAP_SURFACEFMT_Z_D24X8;
-
case PIPE_FORMAT_A8_UNORM:
return SVGA3D_DEVCAP_SURFACEFMT_ALPHA8;
case PIPE_FORMAT_L8_UNORM:
@@ -359,7 +352,8 @@ svga_is_format_supported( struct pipe_screen *screen,
unsigned sample_count,
unsigned tex_usage)
{
- struct svga_winsys_screen *sws = svga_screen(screen)->sws;
+ struct svga_screen *ss = svga_screen(screen);
+ struct svga_winsys_screen *sws = ss->sws;
SVGA3dDevCapIndex index;
SVGA3dDevCapResult result;
@@ -410,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(format) != SVGA3D_FORMAT_INVALID;
+ return svga_translate_format_render(ss, format) != SVGA3D_FORMAT_INVALID;
else
- return svga_translate_format(format) != SVGA3D_FORMAT_INVALID;
+ return svga_translate_format(ss, format) != SVGA3D_FORMAT_INVALID;
}
@@ -525,6 +519,41 @@ svga_screen_create(struct svga_winsys_screen *sws)
sws->get_cap(sws, SVGA3D_DEVCAP_VERTEX_SHADER_VERSION, &result) &&
result.u >= SVGA3DVSVERSION_30 ? TRUE : FALSE;
+ {
+ SVGA3dSurfaceFormatCaps mask;
+ mask.value = 0;
+ mask.zStencil = 1;
+ mask.texture = 1;
+
+ svgascreen->depth.z16 =
+ sws->get_cap(sws, SVGA3D_DEVCAP_SURFACEFMT_Z_D16, &result) &&
+ (result.u & mask.value) == mask.value ?
+ SVGA3D_Z_D16 : SVGA3D_FORMAT_INVALID;
+ svgascreen->depth.z16 =
+ sws->get_cap(sws, SVGA3D_DEVCAP_SURFACEFMT_Z_DF16, &result) &&
+ (result.u & mask.value) == mask.value ?
+ SVGA3D_Z_DF16 : svgascreen->depth.z16;
+
+ svgascreen->depth.x8z24 =
+ sws->get_cap(sws, SVGA3D_DEVCAP_SURFACEFMT_Z_D24X8, &result) &&
+ (result.u & mask.value) == mask.value ?
+ SVGA3D_Z_D24X8 : SVGA3D_FORMAT_INVALID;
+ svgascreen->depth.x8z24 =
+ sws->get_cap(sws, SVGA3D_DEVCAP_SURFACEFMT_Z_DF24, &result) &&
+ (result.u & mask.value) == mask.value ?
+ SVGA3D_Z_DF24 : svgascreen->depth.x8z24;
+
+ svgascreen->depth.s8z24 =
+ sws->get_cap(sws, SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8, &result) &&
+ (result.u & mask.value) == mask.value ?
+ SVGA3D_Z_D24S8 : SVGA3D_FORMAT_INVALID;
+ svgascreen->depth.s8z24 =
+ sws->get_cap(sws, SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8_INT, &result) &&
+ (result.u & mask.value) == mask.value ?
+ SVGA3D_Z_D24S8_INT : svgascreen->depth.s8z24;
+ }
+
+
#if 1
/* Shader model 2.0 is unsupported at the moment. */
if(!svgascreen->use_ps30 || !svgascreen->use_vs30)
diff --git a/src/gallium/drivers/svga/svga_screen.h b/src/gallium/drivers/svga/svga_screen.h
index 6d8d287ce95..1c5eae8e49f 100644
--- a/src/gallium/drivers/svga/svga_screen.h
+++ b/src/gallium/drivers/svga/svga_screen.h
@@ -65,6 +65,14 @@ struct svga_screen
pipe_mutex swc_mutex; /* Used for buffer uploads */
+ /* which formats to translate depth formats into */
+ struct {
+ enum SVGA3dSurfaceFormat z16;
+ /* note gallium order */
+ enum SVGA3dSurfaceFormat x8z24;
+ enum SVGA3dSurfaceFormat s8z24;
+ } depth;
+
struct svga_host_surface_cache cache;
};
diff --git a/src/gallium/drivers/svga/svga_surface.c b/src/gallium/drivers/svga/svga_surface.c
index 3e8fb5f0271..1bcbd3e002b 100644
--- a/src/gallium/drivers/svga/svga_surface.c
+++ b/src/gallium/drivers/svga/svga_surface.c
@@ -187,6 +187,7 @@ svga_create_surface(struct pipe_context *pipe,
struct svga_context *svga = svga_context(pipe);
struct svga_texture *tex = svga_texture(pt);
struct pipe_screen *screen = pipe->screen;
+ struct svga_screen *ss = svga_screen(screen);
struct svga_surface *s;
unsigned face, zslice;
/* XXX surfaces should only be used for rendering purposes nowadays */
@@ -224,7 +225,7 @@ svga_create_surface(struct pipe_context *pipe,
if (!render) {
flags = SVGA3D_SURFACE_HINT_TEXTURE;
- format = svga_translate_format(surf_tmpl->format);
+ format = svga_translate_format(ss, surf_tmpl->format);
} else {
if (surf_tmpl->usage & PIPE_BIND_RENDER_TARGET) {
flags = SVGA3D_SURFACE_HINT_RENDERTARGET;
@@ -232,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(surf_tmpl->format);
+ format = svga_translate_format_render(ss, surf_tmpl->format);
}
assert(format != SVGA3D_FORMAT_INVALID);
@@ -242,7 +243,7 @@ svga_create_surface(struct pipe_context *pipe,
/* Currently only used for compressed textures */
if (render &&
- format != svga_translate_format(surf_tmpl->format)) {
+ format != svga_translate_format(ss, surf_tmpl->format)) {
view = TRUE;
}