*/
static char err_buf[128];
-#if 0
-static void
-svga_destroy_shader_emitter(struct svga_shader_emitter *emit)
-{
- if (emit->buf != err_buf)
- FREE(emit->buf);
-}
-#endif
-
static boolean
svga_shader_expand(struct svga_shader_emitter *emit)
else
new_buf = NULL;
- if (new_buf == NULL) {
+ if (!new_buf) {
emit->ptr = err_buf;
emit->buf = err_buf;
emit->size = sizeof(err_buf);
* it is, it will be copied to a hardware buffer for upload.
*/
struct svga_shader_variant *
-svga_tgsi_vgpu9_translate(const struct svga_shader *shader,
+svga_tgsi_vgpu9_translate(struct svga_context *svga,
+ const struct svga_shader *shader,
const struct svga_compile_key *key, unsigned unit)
{
struct svga_shader_variant *variant = NULL;
struct svga_shader_emitter emit;
+ SVGA_STATS_TIME_PUSH(svga_sws(svga), SVGA_STATS_TIME_TGSIVGPU9TRANSLATE);
+
memset(&emit, 0, sizeof(emit));
emit.size = 1024;
goto fail;
}
+ if (emit.info.indirect_files & (1 << TGSI_FILE_TEMPORARY)) {
+ debug_printf(
+ "svga: indirect indexing of temporary registers is not supported.\n");
+ goto fail;
+ }
+
emit.in_main_func = TRUE;
if (!svga_shader_emit_header(&emit)) {
goto fail;
}
- variant = CALLOC_STRUCT(svga_shader_variant);
- if (variant == NULL)
+ variant = svga_new_shader_variant(svga);
+ if (!variant)
goto fail;
variant->shader = shader;
variant->pstipple_sampler_unit = emit.pstipple_sampler_unit;
+ /* If there was exactly one write to a fragment shader output register
+ * and it came from a constant buffer, we know all fragments will have
+ * the same color (except for blending).
+ */
+ variant->constant_color_output =
+ emit.constant_color_output && emit.num_output_writes == 1;
+
#if 0
if (!svga_shader_verify(variant->tokens, variant->nr_tokens) ||
SVGA_DEBUG & DEBUG_TGSI) {
}
#endif
- return variant;
+ goto done;
- fail:
+fail:
FREE(variant);
- FREE(emit.buf);
- return NULL;
+ if (emit.buf != err_buf)
+ FREE(emit.buf);
+ variant = NULL;
+
+done:
+ SVGA_STATS_TIME_POP(svga_sws(svga));
+ return variant;
}