summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/ilo/ilo_state.c
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2013-08-10 00:48:28 +0800
committerChia-I Wu <[email protected]>2013-08-10 13:01:41 +0800
commitb2f79a3823bd5fca3f3080351f87b41e2396c8f6 (patch)
treefa3845635fae13491b3ee1a7647ad7ba1b96ef00 /src/gallium/drivers/ilo/ilo_state.c
parent637e6a0aa8e5920965a0720673e11622786e86ed (diff)
ilo: 3DSTATE_INDEX_BUFFER may be wrongly skipped
In finalize_index_buffer(), when the current index buffer was destroyed due to u_upload_data(), it may happen that the new index buffer is at the same address as the old one. Comparing the pointers to the two buffers could fail to work, and 3DSTATE_INDEX_BUFFER would be incorrectly skipped. Holding a reference to the current index buffer before calling u_upload_data() should fix the problem.
Diffstat (limited to 'src/gallium/drivers/ilo/ilo_state.c')
-rw-r--r--src/gallium/drivers/ilo/ilo_state.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/gallium/drivers/ilo/ilo_state.c b/src/gallium/drivers/ilo/ilo_state.c
index 86470a784f8..ce6930c4aec 100644
--- a/src/gallium/drivers/ilo/ilo_state.c
+++ b/src/gallium/drivers/ilo/ilo_state.c
@@ -128,13 +128,15 @@ finalize_constant_buffers(struct ilo_context *ilo)
static void
finalize_index_buffer(struct ilo_context *ilo)
{
- const struct pipe_resource *current_hw_res = ilo->ib.hw_resource;
const bool need_upload = (ilo->draw->indexed &&
(ilo->ib.user_buffer || ilo->ib.offset % ilo->ib.index_size));
+ struct pipe_resource *current_hw_res = NULL;
if (!(ilo->dirty & ILO_DIRTY_IB) && !need_upload)
return;
+ pipe_resource_reference(&current_hw_res, ilo->ib.hw_resource);
+
if (need_upload) {
const unsigned offset = ilo->ib.index_size * ilo->draw->start;
const unsigned size = ilo->ib.index_size * ilo->draw->count;
@@ -175,6 +177,8 @@ finalize_index_buffer(struct ilo_context *ilo)
ilo->dirty &= ~ILO_DIRTY_IB;
else
ilo->ib.hw_index_size = ilo->ib.index_size;
+
+ pipe_resource_reference(&current_hw_res, NULL);
}
/**