summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/nine/swapchain9.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/swapchain9.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/swapchain9.c')
-rw-r--r--src/gallium/state_trackers/nine/swapchain9.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c
index 24ff905cd14..de61dad8e09 100644
--- a/src/gallium/state_trackers/nine/swapchain9.c
+++ b/src/gallium/state_trackers/nine/swapchain9.c
@@ -195,7 +195,10 @@ NineSwapChain9_Resize( struct NineSwapChain9 *This,
newBufferCount = pParams->BackBufferCount +
(pParams->SwapEffect != D3DSWAPEFFECT_COPY);
- pf = d3d9_to_pipe_format(pParams->BackBufferFormat);
+ pf = d3d9_to_pipe_format_checked(This->screen, pParams->BackBufferFormat,
+ PIPE_TEXTURE_2D, pParams->MultiSampleType,
+ PIPE_BIND_RENDER_TARGET, FALSE);
+
if (This->actx->linear_framebuffer ||
(pf != PIPE_FORMAT_B8G8R8X8_UNORM &&
pf != PIPE_FORMAT_B8G8R8A8_UNORM) ||
@@ -284,12 +287,18 @@ NineSwapChain9_Resize( struct NineSwapChain9 *This,
}
for (i = 0; i < newBufferCount; ++i) {
- tmplt.format = d3d9_to_pipe_format(pParams->BackBufferFormat);
tmplt.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_TRANSFER_READ |
PIPE_BIND_TRANSFER_WRITE | PIPE_BIND_RENDER_TARGET;
tmplt.nr_samples = pParams->MultiSampleType;
if (!has_present_buffers)
tmplt.bind |= PIPE_BIND_SHARED | PIPE_BIND_SCANOUT | PIPE_BIND_DISPLAY_TARGET;
+ tmplt.format = d3d9_to_pipe_format_checked(This->screen,
+ pParams->BackBufferFormat,
+ PIPE_TEXTURE_2D,
+ tmplt.nr_samples,
+ tmplt.bind, FALSE);
+ if (tmplt.format == PIPE_FORMAT_NONE)
+ return D3DERR_INVALIDCALL;
resource = This->screen->resource_create(This->screen, &tmplt);
if (!resource) {
DBG("Failed to create pipe_resource.\n");
@@ -330,10 +339,17 @@ NineSwapChain9_Resize( struct NineSwapChain9 *This,
pipe_resource_reference(&resource, NULL);
}
if (pParams->EnableAutoDepthStencil) {
- tmplt.format = d3d9_to_pipe_format(pParams->AutoDepthStencilFormat);
tmplt.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_TRANSFER_READ |
PIPE_BIND_TRANSFER_WRITE | PIPE_BIND_DEPTH_STENCIL;
tmplt.nr_samples = pParams->MultiSampleType;
+ tmplt.format = d3d9_to_pipe_format_checked(This->screen,
+ pParams->AutoDepthStencilFormat,
+ PIPE_TEXTURE_2D,
+ tmplt.nr_samples,
+ tmplt.bind,
+ FALSE);
+ if (tmplt.format == PIPE_FORMAT_NONE)
+ return D3DERR_INVALIDCALL;
resource = This->screen->resource_create(This->screen, &tmplt);
if (!resource) {