mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-30 18:40:13 +01:00
svga: Expose the new depth formats
This commit is contained in:
parent
fd69fc8744
commit
4e0ae3e34f
6 changed files with 65 additions and 25 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue