Exemplo n.º 1
0
/**
 * Replace the given shader's instruction with a simple / dummy shader.
 * We use this when normal shader translation fails.
 */
static struct svga_shader_variant *
get_compiled_dummy_vertex_shader(struct svga_context *svga,
                                 struct svga_vertex_shader *vs,
                                 const struct svga_compile_key *key)
{
   const struct tgsi_token *dummy = get_dummy_vertex_shader();
   struct svga_shader_variant *variant;

   if (!dummy) {
      return NULL;
   }

   FREE((void *) vs->base.tokens);
   vs->base.tokens = dummy;

   variant = translate_vertex_program(svga, vs, key);
   return variant;
}
Exemplo n.º 2
0
/**
 * Translate TGSI shader into an svga shader variant.
 */
static enum pipe_error
compile_vs(struct svga_context *svga,
           struct svga_vertex_shader *vs,
           const struct svga_compile_key *key,
           struct svga_shader_variant **out_variant)
{
   struct svga_shader_variant *variant;
   enum pipe_error ret = PIPE_ERROR;

   variant = translate_vertex_program(svga, vs, key);
   if (variant == NULL) {
      debug_printf("Failed to compile vertex shader,"
                   " using dummy shader instead.\n");
      variant = get_compiled_dummy_vertex_shader(svga, vs, key);
   }
   else if (svga_shader_too_large(svga, variant)) {
      /* too big, use dummy shader */
      debug_printf("Shader too large (%u bytes),"
                   " using dummy shader instead.\n",
                   (unsigned) (variant->nr_tokens
                               * sizeof(variant->tokens[0])));
      /* Free the too-large variant */
      svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_VS, variant);
      /* Use simple pass-through shader instead */
      variant = get_compiled_dummy_vertex_shader(svga, vs, key);
   }

   if (!variant) {
      return PIPE_ERROR;
   }

   ret = svga_define_shader(svga, SVGA3D_SHADERTYPE_VS, variant);
   if (ret != PIPE_OK) {
      svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_VS, variant);
      return ret;
   }

   *out_variant = variant;

   return PIPE_OK;
}
Exemplo n.º 3
0
void r3xx_compile_vertex_program(struct r300_vertex_program_compiler* compiler)
{
	compiler->Base.SwizzleCaps = &r300_vertprog_swizzle_caps;

	addArtificialOutputs(compiler);

	{
		struct radeon_program_transformation transformations[] = {
			{ &r300_transform_vertex_alu, 0 },
		};
		radeonLocalTransform(&compiler->Base, 1, transformations);
	}

	if (compiler->Base.Debug) {
		fprintf(stderr, "Vertex program after native rewrite:\n");
		rc_print_program(&compiler->Base.Program);
		fflush(stderr);
	}

	{
		/* Note: This pass has to be done seperately from ALU rewrite,
		 * otherwise non-native ALU instructions with source conflits
		 * will not be treated properly.
		 */
		struct radeon_program_transformation transformations[] = {
			{ &transform_source_conflicts, 0 },
		};
		radeonLocalTransform(&compiler->Base, 1, transformations);
	}

	if (compiler->Base.Debug) {
		fprintf(stderr, "Vertex program after source conflict resolve:\n");
		rc_print_program(&compiler->Base.Program);
		fflush(stderr);
	}

	rc_dataflow_deadcode(&compiler->Base, &dataflow_outputs_mark_used, compiler);

	if (compiler->Base.Debug) {
		fprintf(stderr, "Vertex program after deadcode:\n");
		rc_print_program(&compiler->Base.Program);
		fflush(stderr);
	}

	rc_dataflow_swizzles(&compiler->Base);

	allocate_temporary_registers(compiler);

	if (compiler->Base.Debug) {
		fprintf(stderr, "Vertex program after dataflow:\n");
		rc_print_program(&compiler->Base.Program);
		fflush(stderr);
	}

	translate_vertex_program(compiler);

	rc_constants_copy(&compiler->code->constants, &compiler->Base.Program.Constants);

	compiler->code->InputsRead = compiler->Base.Program.InputsRead;
	compiler->code->OutputsWritten = compiler->Base.Program.OutputsWritten;

	if (compiler->Base.Debug) {
		fprintf(stderr, "Final vertex program code:\n");
		r300_vertex_program_dump(compiler->code);
	}
}