unsigned need_prescale:1;
unsigned undo_viewport:1;
unsigned allow_psiz:1;
+ unsigned need_vertex_id_bias:1;
+
/** The following are all 32-bit bitmasks (per VS input) */
unsigned adjust_attrib_range;
unsigned attrib_is_pure_int;
unsigned need_prescale:1;
unsigned writes_psize:1;
unsigned wide_point:1;
+ unsigned writes_viewport_index:1;
+ unsigned num_prescale:5;
} gs;
/* fragment shader only */
unsigned light_twoside:1;
unsigned front_ccw:1;
unsigned white_fragments:1;
+ unsigned alpha_to_one:1;
unsigned flatshade:1;
unsigned pstipple:1;
unsigned alpha_func:4; /**< SVGA3D_CMP_x */
unsigned write_color0_to_n_cbufs:4;
unsigned aa_point:1;
+ unsigned layer_to_zero:1;
int aa_point_coord_index;
float alpha_ref;
} fs;
+ /* tessellation control shader */
+ struct {
+ unsigned vertices_per_patch:8;
+ unsigned vertices_out:8;
+ enum pipe_prim_type prim_mode:8;
+ enum pipe_tess_spacing spacing:3;
+ unsigned vertices_order_cw:1;
+ unsigned point_mode:1;
+ unsigned passthrough:1;
+ } tcs;
+
+ /* tessellation evaluation shader */
+ struct {
+ unsigned vertices_per_patch:8;
+ unsigned tessfactor_index:8;
+ unsigned need_prescale:1;
+ unsigned need_tessouter:1;
+ unsigned need_tessinner:1;
+ } tes;
+
+ /* compute shader */
+ struct {
+ unsigned grid_size[3];
+ } cs;
+
/* any shader type */
int8_t generic_remap_table[MAX_GENERIC_VARYING];
unsigned num_textures:8;
unsigned num_unnormalized_coords:8;
unsigned clip_plane_enable:PIPE_MAX_CLIP_PLANES;
+ unsigned last_vertex_stage:1;
+ unsigned clamp_vertex_color:1;
unsigned sprite_origin_lower_left:1;
- unsigned sprite_coord_enable;
+ uint16_t sprite_coord_enable;
struct {
unsigned compare_mode:1;
unsigned compare_func:3;
unsigned texel_bias:1;
unsigned width_height_idx:5; /**< texture unit */
unsigned is_array:1;
- unsigned sprite_texgen:1;
unsigned swizzle_r:3;
unsigned swizzle_g:3;
unsigned swizzle_b:3;
unsigned swizzle_a:3;
+ unsigned num_samples:5; /**< Up to 16 samples */
} tex[PIPE_MAX_SAMPLERS];
/* Note: svga_compile_keys_equal() depends on the variable-size
* tex[] array being at the end of this structure.
unsigned writes_psize:1;
unsigned aa_point:1;
} gs;
+ struct {
+ unsigned write_position:1;
+ } vs;
+ unsigned dynamic_indexing:1;
};
/**
/** Parameters used to generate this variant */
struct svga_compile_key key;
+ /* svga shader type */
+ SVGA3dShaderType type;
+
/* Compiled shader tokens:
*/
const unsigned *tokens;
unsigned nr_tokens;
+ /* shader signature */
+ unsigned signatureLen;
+ SVGA3dDXShaderSignatureHeader *signature;
+
/** Per-context shader identifier used with SVGA_3D_CMD_SHADER_DEFINE,
* SVGA_3D_CMD_SET_SHADER and SVGA_3D_CMD_SHADER_DESTROY.
*/
/* GB object buffer containing the bytecode */
struct svga_winsys_gb_shader *gb_shader;
+ /** Next variant */
+ struct svga_shader_variant *next;
+};
+
+
+/**
+ * Shader variant for fragment shader
+ */
+struct svga_fs_variant
+{
+ struct svga_shader_variant base;
+
boolean uses_flat_interp; /** TRUE if flat interpolation qualifier is
* applied to any of the varyings.
*/
/** Is the color output just a constant value? (fragment shader only) */
boolean constant_color_output;
+ /** Bitmask indicating which texture units are doing the shadow
+ * comparison test in the shader rather than the sampler state.
+ */
+ unsigned fs_shadow_compare_units;
+
/** For FS-based polygon stipple */
unsigned pstipple_sampler_unit;
+};
- /** Next variant */
- struct svga_shader_variant *next;
+
+/**
+ * Shader variant for geometry shader
+ */
+struct svga_gs_variant
+{
+ struct svga_shader_variant base;
+};
+
+
+/**
+ * Shader variant for vertex shader
+ */
+struct svga_vs_variant
+{
+ struct svga_shader_variant base;
+};
+
+
+/**
+ * Shader variant for tessellation evaluation shader
+ */
+struct svga_tes_variant
+{
+ struct svga_shader_variant base;
+
+ enum pipe_prim_type prim_mode:8;
+ enum pipe_tess_spacing spacing:3;
+ unsigned vertices_order_cw:1;
+ unsigned point_mode:1;
+};
+
+
+/**
+ * Shader variant for tessellation control shader
+ */
+struct svga_tcs_variant
+{
+ struct svga_shader_variant base;
+};
+
+
+/**
+ * Shader variant for compute shader
+ */
+struct svga_cs_variant
+{
+ struct svga_shader_variant base;
};
};
+struct svga_tcs_shader
+{
+ struct svga_shader base;
+
+ /** Mask of which generic varying variables are written by this shader */
+ uint64_t generic_outputs;
+};
+
+
+struct svga_tes_shader
+{
+ struct svga_shader base;
+
+ /** Mask of which generic varying variables are written by this shader */
+ uint64_t generic_inputs;
+};
+
+
+struct svga_compute_shader
+{
+ struct svga_shader base;
+};
+
+
static inline boolean
svga_compile_keys_equal(const struct svga_compile_key *a,
const struct svga_compile_key *b)
void
svga_init_shader_key_common(const struct svga_context *svga,
- enum pipe_shader_type shader,
+ enum pipe_shader_type shader_type,
+ const struct svga_shader *shader,
struct svga_compile_key *key);
struct svga_shader_variant *
enum pipe_error
svga_define_shader(struct svga_context *svga,
- SVGA3dShaderType type,
struct svga_shader_variant *variant);
enum pipe_error
struct svga_shader_variant *variant);
struct svga_shader_variant *
-svga_new_shader_variant(struct svga_context *svga);
+svga_new_shader_variant(struct svga_context *svga, enum pipe_shader_type type);
-enum pipe_error
+void
svga_destroy_shader_variant(struct svga_context *svga,
- SVGA3dShaderType type,
struct svga_shader_variant *variant);
enum pipe_error
return SVGA3D_SHADERTYPE_GS;
case PIPE_SHADER_FRAGMENT:
return SVGA3D_SHADERTYPE_PS;
+ case PIPE_SHADER_TESS_CTRL:
+ return SVGA3D_SHADERTYPE_HS;
+ case PIPE_SHADER_TESS_EVAL:
+ return SVGA3D_SHADERTYPE_DS;
+ case PIPE_SHADER_COMPUTE:
+ return SVGA3D_SHADERTYPE_CS;
default:
assert(!"Invalid shader type");
return SVGA3D_SHADERTYPE_VS;
}
+static inline struct svga_fs_variant *
+svga_fs_variant(struct svga_shader_variant *variant)
+{
+ assert(!variant || variant->type == SVGA3D_SHADERTYPE_PS);
+ return (struct svga_fs_variant *)variant;
+}
+
+
+static inline struct svga_tes_variant *
+svga_tes_variant(struct svga_shader_variant *variant)
+{
+ assert(!variant || variant->type == SVGA3D_SHADERTYPE_DS);
+ return (struct svga_tes_variant *)variant;
+}
+
+
+static inline struct svga_cs_variant *
+svga_cs_variant(struct svga_shader_variant *variant)
+{
+ assert(!variant || variant->type == SVGA3D_SHADERTYPE_CS);
+ return (struct svga_cs_variant *)variant;
+}
+
+
+/* Returns TRUE if we are currently using flat shading.
+ */
+static inline boolean
+svga_is_using_flat_shading(const struct svga_context *svga)
+{
+ return
+ svga->state.hw_draw.fs ?
+ svga_fs_variant(svga->state.hw_draw.fs)->uses_flat_interp : FALSE;
+}
+
+
#endif /* SVGA_SHADER_H */