summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorAxel Davy <[email protected]>2016-11-13 16:28:33 +0100
committerAxel Davy <[email protected]>2016-12-20 23:47:08 +0100
commit9c4b4e8809f1e6e076c01ba7b11dc1636c2a26b4 (patch)
tree7a7bff1ff1f6b618139550051039776f59b6e511 /src/gallium/state_trackers
parent8a69343f1e8c59137d7b746e5ca8ef1e7944c7d6 (diff)
st/nine: Avoid flushing the queue for queries GetData
Use the newly introduced counter to know when we don't need synchronization. Signed-off-by: Axel Davy <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/nine/nine_state.c33
-rw-r--r--src/gallium/state_trackers/nine/nine_state.h6
-rw-r--r--src/gallium/state_trackers/nine/query9.c12
-rw-r--r--src/gallium/state_trackers/nine/query9.h1
4 files changed, 33 insertions, 19 deletions
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index 56a31520110..d09dabc34c8 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -2712,16 +2712,16 @@ CSMT_ITEM_DO_WAIT(nine_context_destroy_query,
context->pipe->destroy_query(context->pipe, query);
}
-CSMT_ITEM_NO_WAIT(nine_context_begin_query,
- ARG_REF(struct pipe_query, query))
+CSMT_ITEM_NO_WAIT_WITH_COUNTER(nine_context_begin_query,
+ ARG_REF(struct pipe_query, query))
{
struct nine_context *context = &device->context;
(void) context->pipe->begin_query(context->pipe, query);
}
-CSMT_ITEM_NO_WAIT(nine_context_end_query,
- ARG_REF(struct pipe_query, query))
+CSMT_ITEM_NO_WAIT_WITH_COUNTER(nine_context_end_query,
+ ARG_REF(struct pipe_query, query))
{
struct nine_context *context = &device->context;
@@ -2730,15 +2730,28 @@ CSMT_ITEM_NO_WAIT(nine_context_end_query,
boolean
nine_context_get_query_result(struct NineDevice9 *device, struct pipe_query *query,
- boolean flush, boolean wait,
+ unsigned *counter, boolean flush, boolean wait,
union pipe_query_result *result)
{
- struct nine_context *context = &device->context;
+ struct pipe_context *pipe;
+ boolean ret;
- (void) flush;
- if (device->csmt_active)
- nine_csmt_process(device);
- return context->pipe->get_query_result(context->pipe, query, wait, result);
+ if (wait) {
+ if (device->csmt_active)
+ nine_csmt_process(device);
+ } else if (p_atomic_read(counter) > 0) {
+ if (flush && device->csmt_active)
+ nine_queue_flush(device->csmt_ctx->pool);
+ DBG("Pending begin/end. Returning\n");
+ return false;
+ }
+
+ pipe = nine_context_get_pipe_acquire(device);
+ ret = pipe->get_query_result(pipe, query, wait, result);
+ nine_context_get_pipe_release(device);
+
+ DBG("Query result %s\n", ret ? "found" : "not yet available");
+ return ret;
}
/* State defaults */
diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h
index 421f8f97404..6578be363c1 100644
--- a/src/gallium/state_trackers/nine/nine_state.h
+++ b/src/gallium/state_trackers/nine/nine_state.h
@@ -546,14 +546,14 @@ void
nine_context_destroy_query(struct NineDevice9 *device, struct pipe_query *query);
void
-nine_context_begin_query(struct NineDevice9 *device, struct pipe_query *query);
+nine_context_begin_query(struct NineDevice9 *device, unsigned *counter, struct pipe_query *query);
void
-nine_context_end_query(struct NineDevice9 *device, struct pipe_query *query);
+nine_context_end_query(struct NineDevice9 *device, unsigned *counter, struct pipe_query *query);
boolean
nine_context_get_query_result(struct NineDevice9 *device, struct pipe_query *query,
- boolean flush, boolean wait,
+ unsigned *counter, boolean flush, boolean wait,
union pipe_query_result *result);
void nine_state_restore_non_cso(struct NineDevice9 *device);
diff --git a/src/gallium/state_trackers/nine/query9.c b/src/gallium/state_trackers/nine/query9.c
index 6bba4a78524..d98db9eba7e 100644
--- a/src/gallium/state_trackers/nine/query9.c
+++ b/src/gallium/state_trackers/nine/query9.c
@@ -139,7 +139,7 @@ NineQuery9_dtor( struct NineQuery9 *This )
if (This->pq) {
if (This->state == NINE_QUERY_STATE_RUNNING)
- nine_context_end_query(device, This->pq);
+ nine_context_end_query(device, &This->counter, This->pq);
nine_context_destroy_query(device, This->pq);
}
@@ -177,15 +177,15 @@ NineQuery9_Issue( struct NineQuery9 *This,
if (dwIssueFlags == D3DISSUE_BEGIN) {
if (This->state == NINE_QUERY_STATE_RUNNING)
- nine_context_end_query(device, This->pq);
- nine_context_begin_query(device, This->pq);
+ nine_context_end_query(device, &This->counter, This->pq);
+ nine_context_begin_query(device, &This->counter, This->pq);
This->state = NINE_QUERY_STATE_RUNNING;
} else {
if (This->state != NINE_QUERY_STATE_RUNNING &&
This->type != D3DQUERYTYPE_EVENT &&
This->type != D3DQUERYTYPE_TIMESTAMP)
- nine_context_begin_query(device, This->pq);
- nine_context_end_query(device, This->pq);
+ nine_context_begin_query(device, &This->counter, This->pq);
+ nine_context_end_query(device, &This->counter, This->pq);
This->state = NINE_QUERY_STATE_ENDED;
}
return D3D_OK;
@@ -240,7 +240,7 @@ NineQuery9_GetData( struct NineQuery9 *This,
/* Note: We ignore dwGetDataFlags, because get_query_result will
* flush automatically if needed */
- ok = nine_context_get_query_result(device, This->pq,
+ ok = nine_context_get_query_result(device, This->pq, &This->counter,
!!(dwGetDataFlags & D3DGETDATA_FLUSH),
wait_query_result, &presult);
diff --git a/src/gallium/state_trackers/nine/query9.h b/src/gallium/state_trackers/nine/query9.h
index 6397a4c0f6c..cc6c717390d 100644
--- a/src/gallium/state_trackers/nine/query9.h
+++ b/src/gallium/state_trackers/nine/query9.h
@@ -40,6 +40,7 @@ struct NineQuery9
D3DQUERYTYPE type;
enum nine_query_state state;
boolean instant; /* true if D3DISSUE_BEGIN is not needed / invalid */
+ unsigned counter; /* Number of pending Begin/End (0 if internal multithreading off) */
};
static inline struct NineQuery9 *
NineQuery9( void *data )