*/
SVGA3dSurfaceFormat
-svga_translate_format(enum pipe_format format)
+svga_translate_format(struct svga_screen *ss,
+ enum pipe_format format)
{
switch(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;
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:
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;
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;
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 */
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 */
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);
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:
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;
* 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;
}
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)
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;
};
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 */
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;
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);
/* 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;
}