summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2018-03-27 07:28:19 +1000
committerDave Airlie <airlied@redhat.com>2018-06-05 14:45:51 +1000
commita4bc25adf1f70f5de349900cb606ce4f47d1bb95 (patch)
tree5b45a6b32879d65212c932f30a1e25d00167fd04
parent48e1032b3683ac3b59ec3cef60ce845fdd1bbc9d (diff)
vrend: start images
-rw-r--r--src/gallium/include/pipe/p_state.h26
-rw-r--r--src/virgl_protocol.h20
-rw-r--r--src/vrend_decode.c33
-rw-r--r--src/vrend_renderer.c7
4 files changed, 85 insertions, 1 deletions
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 80be1b5..c910fce 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -61,7 +61,8 @@ extern "C" {
#define PIPE_MAX_SHADER_INPUTS 32
#define PIPE_MAX_SHADER_OUTPUTS 48 /* 32 GENERICs + POS, PSIZE, FOG, etc. */
#define PIPE_MAX_SHADER_SAMPLER_VIEWS 32
-#define PIPE_MAX_SHADER_RESOURCES 32
+#define PIPE_MAX_SHADER_BUFFERS 32
+#define PIPE_MAX_SHADER_IMAGES 32
#define PIPE_MAX_TEXTURE_LEVELS 16
#define PIPE_MAX_SO_BUFFERS 4
#define PIPE_MAX_SO_OUTPUTS 64
@@ -385,6 +386,29 @@ struct pipe_sampler_view
/**
+ * A description of a buffer or texture image that can be bound to a shader
+ * stage.
+ */
+struct pipe_image_view
+{
+ struct pipe_resource *resource; /**< resource into which this is a view */
+ enum pipe_format format; /**< typed PIPE_FORMAT_x */
+ unsigned access; /**< PIPE_IMAGE_ACCESS_x */
+
+ union {
+ struct {
+ unsigned first_layer:16; /**< first layer to use for array textures */
+ unsigned last_layer:16; /**< last layer to use for array textures */
+ unsigned level:8; /**< mipmap level to use */
+ } tex;
+ struct {
+ unsigned offset; /**< offset in bytes */
+ unsigned size; /**< size of the accessible sub-range in bytes */
+ } buf;
+ } u;
+};
+
+/**
* Subregion of 1D/2D/3D image resource.
*/
struct pipe_box
diff --git a/src/virgl_protocol.h b/src/virgl_protocol.h
index b273d60..5944925 100644
--- a/src/virgl_protocol.h
+++ b/src/virgl_protocol.h
@@ -85,6 +85,8 @@ enum virgl_context_cmd {
VIRGL_CCMD_BIND_SHADER,
VIRGL_CCMD_SET_TESS_STATE,
VIRGL_CCMD_GET_QUERY_RESULT_QBO,
+ VIRGL_CCMD_SET_SHADER_IMAGES,
+ VIRGL_CCMD_SET_SHADER_BUFFERS,
};
/*
@@ -479,6 +481,24 @@ enum virgl_context_cmd {
#define VIRGL_POLYGON_STIPPLE_SIZE 32
#define VIRGL_POLYGON_STIPPLE_P0 1
+#define VIRGL_SET_SHADER_BUFFER_ELEMENT_SIZE 3
+#define VIRGL_SET_SHADER_BUFFER_SIZE(x) (VIRGL_SET_SHADER_BUFFER_ELEMENT_SIZE * (x)) + 2
+#define VIRGL_SET_SHADER_BUFFER_SHADER_TYPE 1
+#define VIRGL_SET_SHADER_BUFFER_START_SLOT 2
+#define VIRGL_SET_SHADER_BUFFER_OFFSET(x) ((x) * VIRGL_SET_SHADER_BUFFER_ELEMENT_SIZE + 2)
+#define VIRGL_SET_SHADER_BUFFER_LENGTH(x) ((x) * VIRGL_SET_SHADER_BUFFER_ELEMENT_SIZE + 3)
+#define VIRGL_SET_SHADER_BUFFER_RES_HANDLE(x) ((x) * VIRGL_SET_SHADER_BUFFER_ELEMENT_SIZE + 4)
+
+#define VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE 5
+#define VIRGL_SET_SHADER_IMAGE_SIZE(x) (VIRGL_SET_SHADER_BUFFER_ELEMENT_SIZE * (x)) + 2
+#define VIRGL_SET_SHADER_IMAGE_SHADER_TYPE 1
+#define VIRGL_SET_SHADER_IMAGE_START_SLOT 2
+#define VIRGL_SET_SHADER_IMAGE_FORMAT(x) ((x) * VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE + 2)
+#define VIRGL_SET_SHADER_IMAGE_ACCESS(x) ((x) * VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE + 3)
+#define VIRGL_SET_SHADER_IMAGE_LAYER_OFFSET(x) ((x) * VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE + 4)
+#define VIRGL_SET_SHADER_IMAGE_LEVEL_SIZE(x) ((x) * VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE + 5)
+#define VIRGL_SET_SHADER_IMAGE_RES_HANDLE(x) ((x) * VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE + 6)
+
#define VIRGL_BIND_SHADER_SIZE 2
#define VIRGL_BIND_SHADER_HANDLE 1
#define VIRGL_BIND_SHADER_TYPE 2
diff --git a/src/vrend_decode.c b/src/vrend_decode.c
index 3979402..b02b431 100644
--- a/src/vrend_decode.c
+++ b/src/vrend_decode.c
@@ -1079,6 +1079,33 @@ static int vrend_decode_set_tess_state(struct vrend_decode_ctx *ctx,
return 0;
}
+static int vrend_decode_set_shader_buffers(struct vrend_decode_ctx *ctx, uint16_t length)
+{
+
+}
+
+static int vrend_decode_set_shader_images(struct vrend_decode_ctx *ctx, uint16_t length)
+{
+ int num_images;
+ uint32_t shader_type, start_slot;
+ if (length < 2)
+ return EINVAL;
+
+ num_images = (length - 2) / VIRGL_SET_SHADER_IMAGE_ELEMENT_SIZE;
+ shader_type = get_buf_entry(ctx, VIRGL_SET_SHADER_IMAGE_SHADER_TYPE);
+ start_slot = get_buf_entry(ctx, VIRGL_SET_SHADER_IMAGE_START_SLOT);
+ if (shader_type >= PIPE_SHADER_TYPES)
+ return EINVAL;
+
+ if (num_images < 1)
+ return EINVAL;
+ if (start_slot + num_images > PIPE_MAX_SHADER_IMAGES)
+ return EINVAL;
+
+ for (int i = 0; i < num_images; i++) {
+ }
+}
+
static int vrend_decode_set_streamout_targets(struct vrend_decode_ctx *ctx,
uint16_t length)
{
@@ -1306,6 +1333,12 @@ int vrend_decode_block(uint32_t ctx_id, uint32_t *block, int ndw)
break;
case VIRGL_CCMD_GET_QUERY_RESULT_QBO:
ret = vrend_decode_get_query_result_qbo(gdctx, len);
+ break;
+ case VIRGL_CCMD_SET_SHADER_IMAGES:
+ ret = vrend_decode_set_shader_images(gdctx, len);
+ break;
+ case VIRGL_CCMD_SET_SHADER_BUFFERS:
+ ret = vrend_decode_set_shader_buffers(gdctx, len);
break;
default:
ret = EINVAL;
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index 5dd15d6..ccc54a9 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -241,6 +241,13 @@ struct vrend_sampler_view {
struct vrend_resource *texture;
};
+struct vrend_image_view {
+ GLuint id;
+ GLenum access;
+ GLenum format;
+ struct vrend_resource *texture;
+};
+
struct vrend_vertex_element {
struct pipe_vertex_element base;
GLenum type;