aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/include')
-rw-r--r--src/gallium/include/pipe/p_context.h105
-rw-r--r--src/gallium/include/pipe/p_defines.h38
-rw-r--r--src/gallium/include/pipe/p_screen.h12
-rw-r--r--src/gallium/include/pipe/p_shader_tokens.h72
-rw-r--r--src/gallium/include/pipe/p_state.h9
5 files changed, 220 insertions, 16 deletions
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index 7709177444f..f59e3881232 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -64,6 +64,7 @@ struct pipe_vertex_element;
struct pipe_video_buffer;
struct pipe_video_decoder;
struct pipe_viewport_state;
+struct pipe_compute_state;
union pipe_color_union;
union pipe_query_result;
@@ -142,6 +143,10 @@ struct pipe_context {
void (*bind_geometry_sampler_states)(struct pipe_context *,
unsigned num_samplers,
void **samplers);
+ void (*bind_compute_sampler_states)(struct pipe_context *,
+ unsigned start_slot,
+ unsigned num_samplers,
+ void **samplers);
void (*delete_sampler_state)(struct pipe_context *, void *);
void * (*create_rasterizer_state)(struct pipe_context *,
@@ -221,6 +226,26 @@ struct pipe_context {
unsigned num_views,
struct pipe_sampler_view **);
+ void (*set_compute_sampler_views)(struct pipe_context *,
+ unsigned start_slot, unsigned num_views,
+ struct pipe_sampler_view **);
+
+ /**
+ * Bind an array of shader resources that will be used by the
+ * graphics pipeline. Any resources that were previously bound to
+ * the specified range will be unbound after this call.
+ *
+ * \param first first resource to bind.
+ * \param count number of consecutive resources to bind.
+ * \param resources array of pointers to the resources to bind, it
+ * should contain at least \a count elements
+ * unless it's NULL, in which case no new
+ * resources will be bound.
+ */
+ void (*set_shader_resources)(struct pipe_context *,
+ unsigned start, unsigned count,
+ struct pipe_surface **resources);
+
void (*set_vertex_buffers)( struct pipe_context *,
unsigned num_buffers,
const struct pipe_vertex_buffer * );
@@ -410,6 +435,86 @@ struct pipe_context {
*/
struct pipe_video_buffer *(*create_video_buffer)( struct pipe_context *context,
const struct pipe_video_buffer *templat );
+
+ /**
+ * Compute kernel execution
+ */
+ /*@{*/
+ /**
+ * Define the compute program and parameters to be used by
+ * pipe_context::launch_grid.
+ */
+ void *(*create_compute_state)(struct pipe_context *context,
+ const struct pipe_compute_state *);
+ void (*bind_compute_state)(struct pipe_context *, void *);
+ void (*delete_compute_state)(struct pipe_context *, void *);
+
+ /**
+ * Bind an array of shader resources that will be used by the
+ * compute program. Any resources that were previously bound to
+ * the specified range will be unbound after this call.
+ *
+ * \param first first resource to bind.
+ * \param count number of consecutive resources to bind.
+ * \param resources array of pointers to the resources to bind, it
+ * should contain at least \a count elements
+ * unless it's NULL, in which case no new
+ * resources will be bound.
+ */
+ void (*set_compute_resources)(struct pipe_context *,
+ unsigned start, unsigned count,
+ struct pipe_surface **resources);
+
+ /**
+ * Bind an array of buffers to be mapped into the address space of
+ * the GLOBAL resource. Any buffers that were previously bound
+ * between [first, first + count - 1] are unbound after this call.
+ *
+ * \param first first buffer to map.
+ * \param count number of consecutive buffers to map.
+ * \param resources array of pointers to the buffers to map, it
+ * should contain at least \a count elements
+ * unless it's NULL, in which case no new
+ * resources will be bound.
+ * \param handles array of pointers to the memory locations that
+ * will be filled with the respective base
+ * addresses each buffer will be mapped to. It
+ * should contain at least \a count elements,
+ * unless \a resources is NULL in which case \a
+ * handles should be NULL as well.
+ *
+ * Note that the driver isn't required to make any guarantees about
+ * the contents of the \a handles array being valid anytime except
+ * during the subsequent calls to pipe_context::launch_grid. This
+ * means that the only sensible location handles[i] may point to is
+ * somewhere within the INPUT buffer itself. This is so to
+ * accommodate implementations that lack virtual memory but
+ * nevertheless migrate buffers on the fly, leading to resource
+ * base addresses that change on each kernel invocation or are
+ * unknown to the pipe driver.
+ */
+ void (*set_global_binding)(struct pipe_context *context,
+ unsigned first, unsigned count,
+ struct pipe_resource **resources,
+ uint32_t **handles);
+
+ /**
+ * Launch the compute kernel starting from instruction \a pc of the
+ * currently bound compute program.
+ *
+ * \a grid_layout and \a block_layout are arrays of size \a
+ * PIPE_COMPUTE_CAP_GRID_DIMENSION that determine the layout of the
+ * grid (in block units) and working block (in thread units) to be
+ * used, respectively.
+ *
+ * \a input will be used to initialize the INPUT resource, and it
+ * should point to a buffer of at least
+ * pipe_compute_state::req_input_mem bytes.
+ */
+ void (*launch_grid)(struct pipe_context *context,
+ const uint *block_layout, const uint *grid_layout,
+ uint32_t pc, const void *input);
+ /*@}*/
};
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 398cb98248c..1e05cc4caee 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -304,6 +304,9 @@ enum pipe_transfer_usage {
#define PIPE_BIND_STREAM_OUTPUT (1 << 11) /* set_stream_output_buffers */
#define PIPE_BIND_CURSOR (1 << 16) /* mouse cursor */
#define PIPE_BIND_CUSTOM (1 << 17) /* state-tracker/winsys usages */
+#define PIPE_BIND_GLOBAL (1 << 18) /* set_global_binding */
+#define PIPE_BIND_SHADER_RESOURCE (1 << 19) /* set_shader_resources */
+#define PIPE_BIND_COMPUTE_RESOURCE (1 << 20) /* set_compute_resources */
/* The first two flags above were previously part of the amorphous
* TEXTURE_USAGE, most of which are now descriptions of the ways a
@@ -346,7 +349,8 @@ enum pipe_transfer_usage {
#define PIPE_SHADER_VERTEX 0
#define PIPE_SHADER_FRAGMENT 1
#define PIPE_SHADER_GEOMETRY 2
-#define PIPE_SHADER_TYPES 3
+#define PIPE_SHADER_COMPUTE 3
+#define PIPE_SHADER_TYPES 4
/**
@@ -477,9 +481,10 @@ enum pipe_cap {
PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY = 65,
PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY = 66,
PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY = 67,
- PIPE_CAP_USER_INDEX_BUFFERS = 68,
- PIPE_CAP_USER_CONSTANT_BUFFERS = 69,
- PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT = 70
+ PIPE_CAP_COMPUTE = 68,
+ PIPE_CAP_USER_INDEX_BUFFERS = 69,
+ PIPE_CAP_USER_CONSTANT_BUFFERS = 70,
+ PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT = 71
};
/**
@@ -522,9 +527,32 @@ enum pipe_shader_cap
PIPE_SHADER_CAP_INDIRECT_CONST_ADDR = 15,
PIPE_SHADER_CAP_SUBROUTINES = 16, /* BGNSUB, ENDSUB, CAL, RET */
PIPE_SHADER_CAP_INTEGERS = 17,
- PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS = 18
+ PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS = 18,
+ PIPE_SHADER_CAP_PREFERRED_IR = 19
};
+/**
+ * Shader intermediate representation.
+ */
+enum pipe_shader_ir
+{
+ PIPE_SHADER_IR_TGSI
+};
+
+/**
+ * Compute-specific implementation capability. They can be queried
+ * using pipe_screen::get_compute_param.
+ */
+enum pipe_compute_cap
+{
+ PIPE_COMPUTE_CAP_GRID_DIMENSION,
+ PIPE_COMPUTE_CAP_MAX_GRID_SIZE,
+ PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE,
+ PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE,
+ PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE,
+ PIPE_COMPUTE_CAP_MAX_PRIVATE_SIZE,
+ PIPE_COMPUTE_CAP_MAX_INPUT_SIZE
+};
/**
* Composite query types
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
index 45c441b2fcf..7ae7c9a04e1 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -98,6 +98,18 @@ struct pipe_screen {
enum pipe_video_profile profile,
enum pipe_video_cap param );
+ /**
+ * Query a compute-specific capability/parameter/limit.
+ * \param param one of PIPE_COMPUTE_CAP_x
+ * \param ret pointer to a preallocated buffer that will be
+ * initialized to the parameter value, or NULL.
+ * \return size in bytes of the parameter value that would be
+ * returned.
+ */
+ int (*get_compute_param)(struct pipe_screen *,
+ enum pipe_compute_cap param,
+ void *ret);
+
struct pipe_context * (*context_create)( struct pipe_screen *,
void *priv );
diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
index df2dd5e618e..6b58293f409 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -43,6 +43,7 @@ struct tgsi_header
#define TGSI_PROCESSOR_FRAGMENT 0
#define TGSI_PROCESSOR_VERTEX 1
#define TGSI_PROCESSOR_GEOMETRY 2
+#define TGSI_PROCESSOR_COMPUTE 3
struct tgsi_processor
{
@@ -76,6 +77,7 @@ enum tgsi_file_type {
TGSI_FILE_IMMEDIATE_ARRAY =10,
TGSI_FILE_TEMPORARY_ARRAY =11,
TGSI_FILE_RESOURCE =12,
+ TGSI_FILE_SAMPLER_VIEW =13,
TGSI_FILE_COUNT /**< how many TGSI_FILE_ types */
};
@@ -114,12 +116,12 @@ struct tgsi_declaration
unsigned NrTokens : 8; /**< UINT */
unsigned File : 4; /**< one of TGSI_FILE_x */
unsigned UsageMask : 4; /**< bitmask of TGSI_WRITEMASK_x flags */
- unsigned Interpolate : 4; /**< one of TGSI_INTERPOLATE_x */
unsigned Dimension : 1; /**< any extra dimension info? */
unsigned Semantic : 1; /**< BOOL, any semantic info? */
- unsigned Centroid : 1; /**< centroid sampling? */
+ unsigned Interpolate : 1; /**< any interpolation info? */
unsigned Invariant : 1; /**< invariant optimization? */
- unsigned CylindricalWrap:4; /**< TGSI_CYLINDRICAL_WRAP_x flags */
+ unsigned Local : 1; /**< optimize as subroutine local variable? */
+ unsigned Padding : 7;
};
struct tgsi_declaration_range
@@ -134,6 +136,14 @@ struct tgsi_declaration_dimension
unsigned Padding:16;
};
+struct tgsi_declaration_interp
+{
+ unsigned Interpolate : 4; /**< one of TGSI_INTERPOLATE_x */
+ unsigned Centroid : 1; /**< centroid sampling? */
+ unsigned CylindricalWrap:4; /**< TGSI_CYLINDRICAL_WRAP_x flags */
+ unsigned Padding : 23;
+};
+
#define TGSI_SEMANTIC_POSITION 0
#define TGSI_SEMANTIC_COLOR 1
#define TGSI_SEMANTIC_BCOLOR 2 /**< back-face color */
@@ -149,7 +159,11 @@ struct tgsi_declaration_dimension
#define TGSI_SEMANTIC_STENCIL 12
#define TGSI_SEMANTIC_CLIPDIST 13
#define TGSI_SEMANTIC_CLIPVERTEX 14
-#define TGSI_SEMANTIC_COUNT 15 /**< number of semantic values */
+#define TGSI_SEMANTIC_GRID_SIZE 15 /**< grid size in blocks */
+#define TGSI_SEMANTIC_BLOCK_ID 16 /**< id of the current block */
+#define TGSI_SEMANTIC_BLOCK_SIZE 17 /**< block size in threads */
+#define TGSI_SEMANTIC_THREAD_ID 18 /**< block-relative id of the current thread */
+#define TGSI_SEMANTIC_COUNT 19 /**< number of semantic values */
struct tgsi_declaration_semantic
{
@@ -160,12 +174,28 @@ struct tgsi_declaration_semantic
struct tgsi_declaration_resource {
unsigned Resource : 8; /**< one of TGSI_TEXTURE_ */
+ unsigned Raw : 1;
+ unsigned Writable : 1;
+ unsigned Padding : 22;
+};
+
+struct tgsi_declaration_sampler_view {
+ unsigned Resource : 8; /**< one of TGSI_TEXTURE_ */
unsigned ReturnTypeX : 6; /**< one of enum pipe_type */
unsigned ReturnTypeY : 6; /**< one of enum pipe_type */
unsigned ReturnTypeZ : 6; /**< one of enum pipe_type */
unsigned ReturnTypeW : 6; /**< one of enum pipe_type */
};
+/*
+ * Special resources that don't need to be declared. They map to the
+ * GLOBAL/LOCAL/PRIVATE/INPUT compute memory spaces.
+ */
+#define TGSI_RESOURCE_GLOBAL 0x7fff
+#define TGSI_RESOURCE_LOCAL 0x7ffe
+#define TGSI_RESOURCE_PRIVATE 0x7ffd
+#define TGSI_RESOURCE_INPUT 0x7ffc
+
#define TGSI_IMM_FLOAT32 0
#define TGSI_IMM_UINT32 1
#define TGSI_IMM_INT32 2
@@ -363,16 +393,16 @@ struct tgsi_property_data {
#define TGSI_OPCODE_ENDSWITCH 144
/* resource related opcodes */
-#define TGSI_OPCODE_LOAD 145
-#define TGSI_OPCODE_LOAD_MS 146
-#define TGSI_OPCODE_SAMPLE 147
+#define TGSI_OPCODE_SAMPLE 145
+#define TGSI_OPCODE_SAMPLE_I 146
+#define TGSI_OPCODE_SAMPLE_I_MS 147
#define TGSI_OPCODE_SAMPLE_B 148
#define TGSI_OPCODE_SAMPLE_C 149
#define TGSI_OPCODE_SAMPLE_C_LZ 150
#define TGSI_OPCODE_SAMPLE_D 151
#define TGSI_OPCODE_SAMPLE_L 152
#define TGSI_OPCODE_GATHER4 153
-#define TGSI_OPCODE_RESINFO 154
+#define TGSI_OPCODE_SVIEWINFO 154
#define TGSI_OPCODE_SAMPLE_POS 155
#define TGSI_OPCODE_SAMPLE_INFO 156
@@ -381,7 +411,26 @@ struct tgsi_property_data {
#define TGSI_OPCODE_IABS 159
#define TGSI_OPCODE_ISSG 160
-#define TGSI_OPCODE_LAST 161
+#define TGSI_OPCODE_LOAD 161
+#define TGSI_OPCODE_STORE 162
+
+#define TGSI_OPCODE_MFENCE 163
+#define TGSI_OPCODE_LFENCE 164
+#define TGSI_OPCODE_SFENCE 165
+#define TGSI_OPCODE_BARRIER 166
+
+#define TGSI_OPCODE_ATOMUADD 167
+#define TGSI_OPCODE_ATOMXCHG 168
+#define TGSI_OPCODE_ATOMCAS 169
+#define TGSI_OPCODE_ATOMAND 170
+#define TGSI_OPCODE_ATOMOR 171
+#define TGSI_OPCODE_ATOMXOR 172
+#define TGSI_OPCODE_ATOMUMIN 173
+#define TGSI_OPCODE_ATOMUMAX 174
+#define TGSI_OPCODE_ATOMIMIN 175
+#define TGSI_OPCODE_ATOMIMAX 176
+
+#define TGSI_OPCODE_LAST 177
#define TGSI_SAT_NONE 0 /* do not saturate */
#define TGSI_SAT_ZERO_ONE 1 /* clamp to [0,1] */
@@ -441,7 +490,7 @@ struct tgsi_instruction_label
unsigned Padding : 8;
};
-#define TGSI_TEXTURE_UNKNOWN 0
+#define TGSI_TEXTURE_BUFFER 0
#define TGSI_TEXTURE_1D 1
#define TGSI_TEXTURE_2D 2
#define TGSI_TEXTURE_3D 3
@@ -455,7 +504,8 @@ struct tgsi_instruction_label
#define TGSI_TEXTURE_SHADOW1D_ARRAY 11
#define TGSI_TEXTURE_SHADOW2D_ARRAY 12
#define TGSI_TEXTURE_SHADOWCUBE 13
-#define TGSI_TEXTURE_COUNT 14
+#define TGSI_TEXTURE_UNKNOWN 14
+#define TGSI_TEXTURE_COUNT 15
struct tgsi_instruction_texture
{
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 3bc35bc77ce..51a956d9532 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -62,6 +62,7 @@ extern "C" {
#define PIPE_MAX_GEOMETRY_SAMPLERS 16
#define PIPE_MAX_SHADER_INPUTS 32
#define PIPE_MAX_SHADER_OUTPUTS 32
+#define PIPE_MAX_SHADER_SAMPLER_VIEWS 32
#define PIPE_MAX_SHADER_RESOURCES 32
#define PIPE_MAX_TEXTURE_LEVELS 16
#define PIPE_MAX_SO_BUFFERS 4
@@ -337,6 +338,7 @@ struct pipe_surface
unsigned height; /**< logical height in pixels */
unsigned usage; /**< bitmask of PIPE_BIND_x */
+ unsigned writable:1; /**< writable shader resource */
union {
struct {
@@ -591,6 +593,13 @@ struct pipe_resolve_info
unsigned mask; /**< PIPE_MASK_RGBA, Z, S or ZS */
};
+struct pipe_compute_state
+{
+ const void *prog; /**< Compute program to be executed. */
+ unsigned req_local_mem; /**< Required size of the LOCAL resource. */
+ unsigned req_private_mem; /**< Required size of the PRIVATE resource. */
+ unsigned req_input_mem; /**< Required size of the INPUT resource. */
+};
#ifdef __cplusplus
}