summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/nine/adapter9.c
diff options
context:
space:
mode:
authorAxel Davy <[email protected]>2015-01-10 14:58:03 +0100
committerAxel Davy <[email protected]>2015-02-06 00:07:18 +0100
commit27e438e35630819914bd42c5aa27fe6e53ebe491 (patch)
tree4987185039ea57de6f52f3b18a178a82e47fa16c /src/gallium/state_trackers/nine/adapter9.c
parentf8713b1bfd0099e262f1224bb5fb02ee42838d55 (diff)
st/nine: Refactor format d3d9 to pipe conversion
Move the checks of whether the format is supported into a common place. The advantage is that allows to handle when a d3d9 format can be mapped to several formats, and that cards don't support all of them. Reviewed-by: Tiziano Bacocco <[email protected]> Signed-off-by: Axel Davy <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/nine/adapter9.c')
-rw-r--r--src/gallium/state_trackers/nine/adapter9.c87
1 files changed, 35 insertions, 52 deletions
diff --git a/src/gallium/state_trackers/nine/adapter9.c b/src/gallium/state_trackers/nine/adapter9.c
index 154d8beb525..84469b14a47 100644
--- a/src/gallium/state_trackers/nine/adapter9.c
+++ b/src/gallium/state_trackers/nine/adapter9.c
@@ -204,19 +204,15 @@ NineAdapter9_CheckDeviceType( struct NineAdapter9 *This,
hr = NineAdapter9_GetScreen(This, DevType, &screen);
if (FAILED(hr)) { return hr; }
- dfmt = d3d9_to_pipe_format(AdapterFormat);
- bfmt = d3d9_to_pipe_format(BackBufferFormat);
+ dfmt = d3d9_to_pipe_format_checked(screen, AdapterFormat, PIPE_TEXTURE_2D,
+ 1,
+ PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_SHARED, FALSE);
+ bfmt = d3d9_to_pipe_format_checked(screen, BackBufferFormat, PIPE_TEXTURE_2D,
+ 1,
+ PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_SHARED, FALSE);
if (dfmt == PIPE_FORMAT_NONE || bfmt == PIPE_FORMAT_NONE) {
- DBG("Invalid Adapter/BackBufferFormat.\n");
- return D3DERR_NOTAVAILABLE;
- }
-
- if (!screen->is_format_supported(screen, dfmt, PIPE_TEXTURE_2D, 1,
- PIPE_BIND_DISPLAY_TARGET |
- PIPE_BIND_SHARED) ||
- !screen->is_format_supported(screen, bfmt, PIPE_TEXTURE_2D, 1,
- PIPE_BIND_DISPLAY_TARGET |
- PIPE_BIND_SHARED)) {
DBG("Unsupported Adapter/BackBufferFormat.\n");
return D3DERR_NOTAVAILABLE;
}
@@ -258,6 +254,7 @@ NineAdapter9_CheckDeviceFormat( struct NineAdapter9 *This,
enum pipe_format pf;
enum pipe_texture_target target;
unsigned bind = 0;
+ boolean srgb;
/* Check adapter format. */
@@ -271,11 +268,10 @@ NineAdapter9_CheckDeviceFormat( struct NineAdapter9 *This,
hr = NineAdapter9_GetScreen(This, DeviceType, &screen);
if (FAILED(hr))
return hr;
- pf = d3d9_to_pipe_format(AdapterFormat);
- if (pf == PIPE_FORMAT_NONE ||
- !screen->is_format_supported(screen, pf, PIPE_TEXTURE_2D, 0,
+ pf = d3d9_to_pipe_format_checked(screen, AdapterFormat, PIPE_TEXTURE_2D, 0,
PIPE_BIND_DISPLAY_TARGET |
- PIPE_BIND_SHARED)) {
+ PIPE_BIND_SHARED, FALSE);
+ if (pf == PIPE_FORMAT_NONE) {
DBG("AdapterFormat %s not available.\n",
d3dformat_to_string(AdapterFormat));
return D3DERR_NOTAVAILABLE;
@@ -330,12 +326,9 @@ NineAdapter9_CheckDeviceFormat( struct NineAdapter9 *This,
}
- pf = d3d9_to_pipe_format(CheckFormat);
- if (Usage & (D3DUSAGE_QUERY_SRGBREAD | D3DUSAGE_QUERY_SRGBWRITE))
- pf = util_format_srgb(pf);
-
- if (pf == PIPE_FORMAT_NONE ||
- !screen->is_format_supported(screen, pf, target, 0, bind)) {
+ srgb = (Usage & (D3DUSAGE_QUERY_SRGBREAD | D3DUSAGE_QUERY_SRGBWRITE)) != 0;
+ pf = d3d9_to_pipe_format_checked(screen, CheckFormat, target, 0, bind, srgb);
+ if (pf == PIPE_FORMAT_NONE) {
DBG("NOT AVAILABLE\n");
return D3DERR_NOTAVAILABLE;
}
@@ -362,7 +355,6 @@ NineAdapter9_CheckDeviceMultiSampleType( struct NineAdapter9 *This,
struct pipe_screen *screen;
HRESULT hr;
enum pipe_format pf;
- unsigned bind;
DBG("This=%p DeviceType=%s SurfaceFormat=%s Windowed=%i MultiSampleType=%u "
"pQualityLevels=%p\n", This, nine_D3DDEVTYPE_to_str(DeviceType),
@@ -373,13 +365,11 @@ NineAdapter9_CheckDeviceMultiSampleType( struct NineAdapter9 *This,
if (FAILED(hr))
return hr;
- pf = d3d9_to_pipe_format(SurfaceFormat);
- bind = util_format_is_depth_or_stencil(pf) ?
- PIPE_BIND_DEPTH_STENCIL : PIPE_BIND_RENDER_TARGET;
+ pf = d3d9_to_pipe_format_checked_no_bind(screen, SurfaceFormat,
+ PIPE_TEXTURE_2D,
+ MultiSampleType, FALSE);
- if (pf == PIPE_FORMAT_NONE ||
- !screen->is_format_supported(screen, pf, PIPE_TEXTURE_2D,
- MultiSampleType, bind)) {
+ if (pf == PIPE_FORMAT_NONE) {
DBG("%s with %u samples not available.\n",
d3dformat_to_string(SurfaceFormat), MultiSampleType);
return D3DERR_NOTAVAILABLE;
@@ -437,27 +427,23 @@ NineAdapter9_CheckDepthStencilMatch( struct NineAdapter9 *This,
hr = NineAdapter9_GetScreen(This, DeviceType, &screen);
if (FAILED(hr)) { return hr; }
- dfmt = d3d9_to_pipe_format(AdapterFormat);
- bfmt = d3d9_to_pipe_format(RenderTargetFormat);
+ dfmt = d3d9_to_pipe_format_checked(screen, AdapterFormat, PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_SHARED, FALSE);
+ bfmt = d3d9_to_pipe_format_checked(screen, RenderTargetFormat,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_RENDER_TARGET, FALSE);
if (RenderTargetFormat == D3DFMT_NULL)
bfmt = dfmt;
- zsfmt = d3d9_to_pipe_format(DepthStencilFormat);
+ zsfmt = d3d9_to_pipe_format_checked(screen, DepthStencilFormat,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_DEPTH_STENCIL, FALSE);
if (dfmt == PIPE_FORMAT_NONE ||
bfmt == PIPE_FORMAT_NONE ||
zsfmt == PIPE_FORMAT_NONE) {
return D3DERR_NOTAVAILABLE;
}
- if (!screen->is_format_supported(screen, dfmt, PIPE_TEXTURE_2D, 0,
- PIPE_BIND_DISPLAY_TARGET |
- PIPE_BIND_SHARED) ||
- !screen->is_format_supported(screen, bfmt, PIPE_TEXTURE_2D, 0,
- PIPE_BIND_RENDER_TARGET) ||
- !screen->is_format_supported(screen, zsfmt, PIPE_TEXTURE_2D, 0,
- PIPE_BIND_DEPTH_STENCIL)) {
- return D3DERR_NOTAVAILABLE;
- }
-
return D3D_OK;
}
@@ -484,17 +470,14 @@ NineAdapter9_CheckDeviceFormatConversion( struct NineAdapter9 *This,
hr = NineAdapter9_GetScreen(This, DeviceType, &screen);
if (FAILED(hr)) { return hr; }
- dfmt = d3d9_to_pipe_format(TargetFormat);
- bfmt = d3d9_to_pipe_format(SourceFormat);
+ dfmt = d3d9_to_pipe_format_checked(screen, TargetFormat, PIPE_TEXTURE_2D, 1,
+ PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_SHARED, FALSE);
+ bfmt = d3d9_to_pipe_format_checked(screen, SourceFormat, PIPE_TEXTURE_2D, 1,
+ PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_SHARED, FALSE);
+
if (dfmt == PIPE_FORMAT_NONE || bfmt == PIPE_FORMAT_NONE) {
- return D3DERR_NOTAVAILABLE;
- }
- if (!screen->is_format_supported(screen, dfmt, PIPE_TEXTURE_2D, 1,
- PIPE_BIND_DISPLAY_TARGET |
- PIPE_BIND_SHARED) ||
- !screen->is_format_supported(screen, bfmt, PIPE_TEXTURE_2D, 1,
- PIPE_BIND_DISPLAY_TARGET |
- PIPE_BIND_SHARED)) {
DBG("%s to %s not supported.\n",
d3dformat_to_string(SourceFormat),
d3dformat_to_string(TargetFormat));