aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2018-05-22 09:32:42 +1000
committerDave Airlie <[email protected]>2019-01-31 11:23:38 +1000
commit9279a28f07fd65fa94831f7f9fb80b35921f6805 (patch)
tree7ca3776a22df8debf1a56032c312b14f86b40acf
parent38658c6d4dda1df12690c1f4c01b993862d6fe68 (diff)
virgl: ARB_query_buffer_object support
v1.1: fix size define. Reviewed-by: Gurchetan Singh <[email protected]>
-rw-r--r--src/gallium/drivers/virgl/virgl_encode.c16
-rw-r--r--src/gallium/drivers/virgl/virgl_encode.h8
-rw-r--r--src/gallium/drivers/virgl/virgl_hw.h2
-rw-r--r--src/gallium/drivers/virgl/virgl_protocol.h11
-rw-r--r--src/gallium/drivers/virgl/virgl_query.c17
-rw-r--r--src/gallium/drivers/virgl/virgl_resource.h2
-rw-r--r--src/gallium/drivers/virgl/virgl_screen.c3
7 files changed, 58 insertions, 1 deletions
diff --git a/src/gallium/drivers/virgl/virgl_encode.c b/src/gallium/drivers/virgl/virgl_encode.c
index 403f54e2842..5b8575699dc 100644
--- a/src/gallium/drivers/virgl/virgl_encode.c
+++ b/src/gallium/drivers/virgl/virgl_encode.c
@@ -1075,6 +1075,22 @@ int virgl_encode_host_debug_flagstring(struct virgl_context *ctx,
virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_SET_DEBUG_FLAGS, 0, sslen));
virgl_encoder_write_block(ctx->cbuf, (const uint8_t *)flagstring, string_length);
+ return 0;
+}
+int virgl_encode_get_query_result_qbo(struct virgl_context *ctx,
+ uint32_t handle,
+ struct virgl_resource *res, boolean wait,
+ uint32_t result_type,
+ uint32_t offset,
+ uint32_t index)
+{
+ virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_GET_QUERY_RESULT_QBO, 0, VIRGL_QUERY_RESULT_QBO_SIZE));
+ virgl_encoder_write_dword(ctx->cbuf, handle);
+ virgl_encoder_write_res(ctx, res);
+ virgl_encoder_write_dword(ctx->cbuf, wait ? 1 : 0);
+ virgl_encoder_write_dword(ctx->cbuf, result_type);
+ virgl_encoder_write_dword(ctx->cbuf, offset);
+ virgl_encoder_write_dword(ctx->cbuf, index);
return 0;
}
diff --git a/src/gallium/drivers/virgl/virgl_encode.h b/src/gallium/drivers/virgl/virgl_encode.h
index f3729e8e920..70fae1db4e5 100644
--- a/src/gallium/drivers/virgl/virgl_encode.h
+++ b/src/gallium/drivers/virgl/virgl_encode.h
@@ -279,4 +279,12 @@ int virgl_encode_texture_barrier(struct virgl_context *ctx,
int virgl_encode_host_debug_flagstring(struct virgl_context *ctx,
const char *envname);
+
+int virgl_encode_get_query_result_qbo(struct virgl_context *ctx,
+ uint32_t handle,
+ struct virgl_resource *res, boolean wait,
+ uint32_t result_type,
+ uint32_t offset,
+ uint32_t index);
+
#endif
diff --git a/src/gallium/drivers/virgl/virgl_hw.h b/src/gallium/drivers/virgl/virgl_hw.h
index 7b4c063f353..8759e577077 100644
--- a/src/gallium/drivers/virgl/virgl_hw.h
+++ b/src/gallium/drivers/virgl/virgl_hw.h
@@ -233,6 +233,7 @@ enum virgl_formats {
#define VIRGL_CAP_TGSI_COMPONENTS (1 << 13)
#define VIRGL_CAP_GUEST_MAY_INIT_LOG (1 << 14)
#define VIRGL_CAP_SRGB_WRITE_CONTROL (1 << 15)
+#define VIRGL_CAP_QBO (1 << 16)
/* virgl bind flags - these are compatible with mesa 10.5 gallium.
* but are fixed, no other should be passed to virgl either.
@@ -246,6 +247,7 @@ enum virgl_formats {
#define VIRGL_BIND_DISPLAY_TARGET (1 << 7)
#define VIRGL_BIND_STREAM_OUTPUT (1 << 11)
#define VIRGL_BIND_SHADER_BUFFER (1 << 14)
+#define VIRGL_BIND_QUERY_BUFFER (1 << 15)
#define VIRGL_BIND_CURSOR (1 << 16)
#define VIRGL_BIND_CUSTOM (1 << 17)
#define VIRGL_BIND_SCANOUT (1 << 18)
diff --git a/src/gallium/drivers/virgl/virgl_protocol.h b/src/gallium/drivers/virgl/virgl_protocol.h
index 7c9ea9f7254..57333553d77 100644
--- a/src/gallium/drivers/virgl/virgl_protocol.h
+++ b/src/gallium/drivers/virgl/virgl_protocol.h
@@ -93,6 +93,7 @@ enum virgl_context_cmd {
VIRGL_CCMD_TEXTURE_BARRIER,
VIRGL_CCMD_SET_ATOMIC_BUFFERS,
VIRGL_CCMD_SET_DEBUG_FLAGS,
+ VIRGL_CCMD_GET_QUERY_RESULT_QBO,
};
/*
@@ -448,6 +449,7 @@ enum virgl_context_cmd {
#define VIRGL_QUERY_END_HANDLE 1
+#define VIRGL_QUERY_RESULT_SIZE 2
#define VIRGL_QUERY_RESULT_HANDLE 1
#define VIRGL_QUERY_RESULT_WAIT 2
@@ -554,4 +556,13 @@ enum virgl_context_cmd {
#define VIRGL_SET_ATOMIC_BUFFER_LENGTH(x) ((x) * VIRGL_SET_ATOMIC_BUFFER_ELEMENT_SIZE + 3)
#define VIRGL_SET_ATOMIC_BUFFER_RES_HANDLE(x) ((x) * VIRGL_SET_ATOMIC_BUFFER_ELEMENT_SIZE + 4)
+/* qbo */
+#define VIRGL_QUERY_RESULT_QBO_SIZE 6
+#define VIRGL_QUERY_RESULT_QBO_HANDLE 1
+#define VIRGL_QUERY_RESULT_QBO_QBO_HANDLE 2
+#define VIRGL_QUERY_RESULT_QBO_WAIT 3
+#define VIRGL_QUERY_RESULT_QBO_RESULT_TYPE 4
+#define VIRGL_QUERY_RESULT_QBO_OFFSET 5
+#define VIRGL_QUERY_RESULT_QBO_INDEX 6
+
#endif
diff --git a/src/gallium/drivers/virgl/virgl_query.c b/src/gallium/drivers/virgl/virgl_query.c
index a75b29c7c9b..23e24c53b02 100644
--- a/src/gallium/drivers/virgl/virgl_query.c
+++ b/src/gallium/drivers/virgl/virgl_query.c
@@ -205,6 +205,22 @@ virgl_set_active_query_state(struct pipe_context *pipe, boolean enable)
{
}
+static void
+virgl_get_query_result_resource(struct pipe_context *ctx,
+ struct pipe_query *q,
+ boolean wait,
+ enum pipe_query_value_type result_type,
+ int index,
+ struct pipe_resource *resource,
+ unsigned offset)
+{
+ struct virgl_context *vctx = virgl_context(ctx);
+ struct virgl_query *query = virgl_query(q);
+ struct virgl_resource *qbo = (struct virgl_resource *)resource;
+
+ virgl_encode_get_query_result_qbo(vctx, query->handle, qbo, wait, result_type, offset, index);
+}
+
void virgl_init_query_functions(struct virgl_context *vctx)
{
vctx->base.render_condition = virgl_render_condition;
@@ -214,4 +230,5 @@ void virgl_init_query_functions(struct virgl_context *vctx)
vctx->base.end_query = virgl_end_query;
vctx->base.get_query_result = virgl_get_query_result;
vctx->base.set_active_query_state = virgl_set_active_query_state;
+ vctx->base.get_query_result_resource = virgl_get_query_result_resource;
}
diff --git a/src/gallium/drivers/virgl/virgl_resource.h b/src/gallium/drivers/virgl/virgl_resource.h
index e211fb881b1..1dc789c4560 100644
--- a/src/gallium/drivers/virgl/virgl_resource.h
+++ b/src/gallium/drivers/virgl/virgl_resource.h
@@ -106,6 +106,8 @@ static inline unsigned pipe_to_virgl_bind(unsigned pbind)
outbind |= VIRGL_BIND_SCANOUT;
if (pbind & PIPE_BIND_SHADER_BUFFER)
outbind |= VIRGL_BIND_SHADER_BUFFER;
+ if (pbind & PIPE_BIND_QUERY_BUFFER)
+ outbind |= VIRGL_BIND_QUERY_BUFFER;
return outbind;
}
diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c
index 9a8d0e64848..72afd4d95f0 100644
--- a/src/gallium/drivers/virgl/virgl_screen.c
+++ b/src/gallium/drivers/virgl/virgl_screen.c
@@ -258,6 +258,8 @@ virgl_get_param(struct pipe_screen *screen, enum pipe_cap param)
case PIPE_CAP_TEXTURE_FLOAT_LINEAR:
case PIPE_CAP_TEXTURE_HALF_FLOAT_LINEAR:
return 1; /* TODO: need to introduce a hw-cap for this */
+ case PIPE_CAP_QUERY_BUFFER_OBJECT:
+ return vscreen->caps.caps.v2.capability_bits & VIRGL_CAP_QBO;
case PIPE_CAP_TEXTURE_GATHER_SM5:
case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
case PIPE_CAP_FAKE_SW_MSAA:
@@ -280,7 +282,6 @@ virgl_get_param(struct pipe_screen *screen, enum pipe_cap param)
case PIPE_CAP_INVALIDATE_BUFFER:
case PIPE_CAP_GENERATE_MIPMAP:
case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:
- case PIPE_CAP_QUERY_BUFFER_OBJECT:
case PIPE_CAP_STRING_MARKER:
case PIPE_CAP_QUERY_MEMORY_INFO:
case PIPE_CAP_PCI_GROUP: