summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAxel Davy <[email protected]>2015-01-17 13:43:38 +0100
committerAxel Davy <[email protected]>2015-02-06 00:07:19 +0100
commit8b901e3011c268d0a093a65b072bb51db0dcd251 (patch)
tree2ccd55d543839a61e161e15461bb2edc607020e1 /src
parent792af626d4e82dae728801ee6ca8c4c0f3d37f68 (diff)
st/nine: Fix present_buffers allocation
If has_present_buffers was false at first, but after a device reset, it turns true (for example if we begin to render to a multisampled back buffer), there was a crash due to present_buffers being uninitialised. This patch fixes it. Reviewed-by: Tiziano Bacocco <[email protected]> Signed-off-by: Axel Davy <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/state_trackers/nine/swapchain9.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c
index de61dad8e09..af6fe6e63fa 100644
--- a/src/gallium/state_trackers/nine/swapchain9.c
+++ b/src/gallium/state_trackers/nine/swapchain9.c
@@ -271,12 +271,6 @@ NineSwapChain9_Resize( struct NineSwapChain9 *This,
if (!bufs)
return E_OUTOFMEMORY;
This->buffers = bufs;
- if (has_present_buffers) {
- This->present_buffers = REALLOC(This->present_buffers,
- This->present_buffers == NULL ? 0 : oldBufferCount * sizeof(struct pipe_resource *),
- newBufferCount * sizeof(struct pipe_resource *));
- memset(This->present_buffers, 0, newBufferCount * sizeof(struct pipe_resource *));
- }
This->present_handles = REALLOC(This->present_handles,
oldBufferCount * sizeof(D3DWindowBuffer *),
newBufferCount * sizeof(D3DWindowBuffer *));
@@ -286,6 +280,15 @@ NineSwapChain9_Resize( struct NineSwapChain9 *This,
}
}
+ if (has_present_buffers &&
+ (newBufferCount != oldBufferCount || !This->present_buffers)) {
+ This->present_buffers = REALLOC(This->present_buffers,
+ This->present_buffers == NULL ? 0 :
+ oldBufferCount * sizeof(struct pipe_resource *),
+ newBufferCount * sizeof(struct pipe_resource *));
+ memset(This->present_buffers, 0, newBufferCount * sizeof(struct pipe_resource *));
+ }
+
for (i = 0; i < newBufferCount; ++i) {
tmplt.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_TRANSFER_READ |
PIPE_BIND_TRANSFER_WRITE | PIPE_BIND_RENDER_TARGET;