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