struct brw_shader {
struct gl_shader base;
+ bool compiled_once;
+
/** Shader IR transformed for native compile, at link time. */
struct exec_list *ir;
};
struct gl_shader_program base;
};
-enum param_conversion {
- PARAM_NO_CONVERT,
- PARAM_CONVERT_F2I,
- PARAM_CONVERT_F2U,
- PARAM_CONVERT_F2B,
- PARAM_CONVERT_ZERO,
-};
-
/* Data about a particular attempt to compile a program. Note that
* there can be many of these, each in a different GL state
* corresponding to a different brw_wm_prog_key struct, with different
- * compiled programs:
+ * compiled programs.
+ *
+ * Note: brw_wm_prog_data_compare() must be updated when adding fields to this
+ * struct!
*/
struct brw_wm_prog_data {
GLuint curb_read_length;
*/
uint32_t barycentric_interp_modes;
- /* Pointer to tracked values (only valid once
+ /* Pointers to tracked values (only valid once
* _mesa_load_state_parameters has been called at runtime).
+ *
+ * These must be the last fields of the struct (see
+ * brw_wm_prog_data_compare()).
*/
- const float *param[MAX_UNIFORMS * 4]; /* should be: BRW_MAX_CURBE */
- enum param_conversion param_convert[MAX_UNIFORMS * 4];
- const float *pull_param[MAX_UNIFORMS * 4];
- enum param_conversion pull_param_convert[MAX_UNIFORMS * 4];
+ const float **param;
+ const float **pull_param;
};
/**
unsigned svbi_postincrement_value;
};
+/* Note: brw_vs_prog_data_compare() must be updated when adding fields to this
+ * struct!
+ */
struct brw_vs_prog_data {
struct brw_vue_map vue_map;
*/
GLuint urb_entry_size;
- const float *param[MAX_UNIFORMS * 4]; /* should be: BRW_MAX_CURBE */
- const float *pull_param[MAX_UNIFORMS * 4];
-
bool uses_new_param_layout;
bool uses_vertexid;
bool userclip;
int num_surfaces;
+
+ /* These pointers must appear last. See brw_vs_prog_data_compare(). */
+ const float **param;
+ const float **pull_param;
};
/** Maximum number of actual buffers used for stream output */
#define BRW_MAX_SOL_BUFFERS 4
+#define BRW_MAX_WM_UBOS 12
+#define BRW_MAX_VS_UBOS 12
+
/**
* Helpers to create Surface Binding Table indexes for draw buffers,
* textures, and constant buffers.
* | . | . |
* | : | : |
* | 24 | Texture 15 |
+ * |-----|-------------------------|
+ * | 25 | UBO 0 |
+ * | . | . |
+ * | : | : |
+ * | 36 | UBO 11 |
* +-------------------------------+
*
* Our VS binding tables are programmed as follows:
* | . | . |
* | : | : |
* | 16 | Texture 15 |
+ * +-----+-------------------------+
+ * | 17 | UBO 0 |
+ * | . | . |
+ * | : | : |
+ * | 28 | UBO 11 |
* +-------------------------------+
*
* Our (gen6) GS binding tables are programmed as follows:
#define SURF_INDEX_DRAW(d) (d)
#define SURF_INDEX_FRAG_CONST_BUFFER (BRW_MAX_DRAW_BUFFERS + 1)
#define SURF_INDEX_TEXTURE(t) (BRW_MAX_DRAW_BUFFERS + 2 + (t))
+#define SURF_INDEX_WM_UBO(u) (SURF_INDEX_TEXTURE(BRW_MAX_TEX_UNIT) + u)
/** Maximum size of the binding table. */
-#define BRW_MAX_WM_SURFACES SURF_INDEX_TEXTURE(BRW_MAX_TEX_UNIT)
+#define BRW_MAX_WM_SURFACES SURF_INDEX_WM_UBO(BRW_MAX_WM_UBOS)
#define SURF_INDEX_VERT_CONST_BUFFER (0)
#define SURF_INDEX_VS_TEXTURE(t) (SURF_INDEX_VERT_CONST_BUFFER + 1 + (t))
-#define BRW_MAX_VS_SURFACES SURF_INDEX_VS_TEXTURE(BRW_MAX_TEX_UNIT)
+#define SURF_INDEX_VS_UBO(u) (SURF_INDEX_VS_TEXTURE(BRW_MAX_TEX_UNIT) + u)
+#define BRW_MAX_VS_SURFACES SURF_INDEX_VS_UBO(BRW_MAX_VS_UBOS)
#define SURF_INDEX_SOL_BINDING(t) ((t))
#define BRW_MAX_GS_SURFACES SURF_INDEX_SOL_BINDING(BRW_MAX_SOL_BINDINGS)
};
+typedef bool (*cache_aux_compare_func)(const void *a, const void *b,
+ int aux_size, const void *key);
+typedef void (*cache_aux_free_func)(const void *aux);
struct brw_cache {
struct brw_context *brw;
uint32_t next_offset;
bool bo_used_by_gpu;
+
+ /**
+ * Optional functions used in determining whether the prog_data for a new
+ * cache item matches an existing cache item (in case there's relevant data
+ * outside of the prog_data). If NULL, a plain memcmp is done.
+ */
+ cache_aux_compare_func aux_compare[BRW_MAX_CACHE];
+ /** Optional functions for freeing other pointers attached to a prog_data. */
+ cache_aux_free_func aux_free[BRW_MAX_CACHE];
};
bool has_pln;
bool precompile;
+ /**
+ * Some versions of Gen hardware don't do centroid interpolation correctly
+ * on unlit pixels, causing incorrect values for derivatives near triangle
+ * edges. Enabling this flag causes the fragment shader to use
+ * non-centroid interpolation for unlit pixels, at the expense of two extra
+ * fragment shader instructions.
+ */
+ bool needs_unlit_centroid_workaround;
+
struct {
struct brw_state_flags dirty;
} state;
drm_intel_bo *scratch_bo;
+ /**
+ * Buffer object used in place of multisampled null render targets on
+ * Gen6. See brw_update_null_renderbuffer_surface().
+ */
+ drm_intel_bo *multisampled_null_render_target_bo;
+
/** Offset in the program cache to the WM program */
uint32_t prog_offset;
uint32_t offset_0_batch_start;
uint32_t primitives_generated;
uint32_t primitives_written;
+ bool counting_primitives_generated;
+ bool counting_primitives_written;
} sol;
uint32_t render_target_format[MESA_FORMAT_COUNT];
bool brwCreateContext(int api,
const struct gl_config *mesaVis,
__DRIcontext *driContextPriv,
+ unsigned major_version,
+ unsigned minor_version,
+ uint32_t flags,
+ unsigned *error,
void *sharedContextPrivate);
+/*======================================================================
+ * brw_misc_state.c
+ */
+void brw_get_depthstencil_tile_masks(struct intel_mipmap_tree *depth_mt,
+ struct intel_mipmap_tree *stencil_mt,
+ uint32_t *out_tile_mask_x,
+ uint32_t *out_tile_mask_y);
+void brw_workaround_depthstencil_alignment(struct brw_context *brw);
+
/*======================================================================
* brw_queryobj.c
*/
struct gl_buffer_object *buffer_obj,
uint32_t *out_offset, unsigned num_vector_components,
unsigned stride_dwords, unsigned offset_dwords);
+void brw_upload_ubo_surfaces(struct brw_context *brw,
+ struct gl_shader *shader,
+ uint32_t *surf_offsets);
/* gen6_sol.c */
void
return (const struct brw_fragment_program *) p;
}
-static inline
-float convert_param(enum param_conversion conversion, const float *param)
-{
- union {
- float f;
- uint32_t u;
- int32_t i;
- } fi;
-
- switch (conversion) {
- case PARAM_NO_CONVERT:
- return *param;
- case PARAM_CONVERT_F2I:
- fi.i = *param;
- return fi.f;
- case PARAM_CONVERT_F2U:
- fi.u = *param;
- return fi.f;
- case PARAM_CONVERT_F2B:
- if (*param != 0.0)
- fi.i = 1;
- else
- fi.i = 0;
- return fi.f;
- case PARAM_CONVERT_ZERO:
- return 0.0;
- default:
- return *param;
- }
-}
-
/**
* Pre-gen6, the register file of the EUs was shared between threads,
* and each thread used some subset allocated on a 16-register block
}
bool brw_do_cubemap_normalize(struct exec_list *instructions);
+bool brw_lower_texture_gradients(struct exec_list *instructions);
+
+struct opcode_desc {
+ char *name;
+ int nsrc;
+ int ndst;
+};
+
+extern const struct opcode_desc opcode_descs[128];
#ifdef __cplusplus
}