Change the fragment shader signature to better match actual
arguments that we need there.
This commit is contained in:
@@ -796,18 +796,19 @@ typedef int (*fragment_shader_runner)(float x, float y,
|
||||
struct tgsi_interp_coef *coef,
|
||||
float (*consts)[4], int num_consts,
|
||||
struct tgsi_sampler *samplers,
|
||||
int num_samplers);
|
||||
unsigned *sampler_units);
|
||||
|
||||
int gallivm_fragment_shader_exec(struct gallivm_prog *prog,
|
||||
float x, float y,
|
||||
float (*dests)[32][4],
|
||||
struct tgsi_interp_coef *coef,
|
||||
float (*consts)[4],
|
||||
struct tgsi_sampler *samplers,
|
||||
int num_samplers)
|
||||
unsigned *sampler_units)
|
||||
{
|
||||
fragment_shader_runner runner = reinterpret_cast<fragment_shader_runner>(prog->function);
|
||||
assert(runner);
|
||||
runner(x, y, dests, coef, consts, prog->num_consts, samplers, num_samplers);
|
||||
runner(x, y, dests, coef, consts, prog->num_consts, samplers, sampler_units);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,8 @@ struct tgsi_token;
|
||||
|
||||
struct gallivm_prog;
|
||||
struct gallivm_cpu_engine;
|
||||
struct tgsi_interp_coef;
|
||||
struct tgsi_sampler;
|
||||
|
||||
enum gallivm_shader_type {
|
||||
GALLIVM_VS,
|
||||
@@ -62,11 +64,11 @@ int gallivm_prog_exec(struct gallivm_prog *prog,
|
||||
int num_attribs);
|
||||
int gallivm_fragment_shader_exec(struct gallivm_prog *prog,
|
||||
float x, float y,
|
||||
float (*dests)[4],
|
||||
float (*dests)[32][4],
|
||||
struct tgsi_interp_coef *coef,
|
||||
float (*consts)[4],
|
||||
struct tgsi_sampler *samplers,
|
||||
int num_samplers);
|
||||
unsigned *sampler_units);
|
||||
void gallivm_prog_dump(struct gallivm_prog *prog, const char *file_prefix);
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -221,20 +221,42 @@ struct tgsi_interp_coef
|
||||
float dadx[NUM_CHANNELS];
|
||||
float dady[NUM_CHANNELS];
|
||||
};
|
||||
|
||||
int run_fragment_shader(float x, float y,
|
||||
float (*dests)[32][4],
|
||||
struct tgsi_interp_coef *coef,
|
||||
float (*consts)[4],
|
||||
float (*aconsts)[4],
|
||||
int num_consts,
|
||||
struct tgsi_sampler *samplers,
|
||||
int num_samplers)
|
||||
unsigned *sampler_units)
|
||||
{
|
||||
float4 inputs[4][16];
|
||||
float4 consts[32];
|
||||
float4 results[4][16];
|
||||
float4 temps[128];//MAX_PROGRAM_TEMPS
|
||||
|
||||
float4 fr1, fr2, fr3, fr4;
|
||||
fr1.x = x;
|
||||
fr1.y = y;
|
||||
fr2.x = x + 1.f;
|
||||
fr2.y = y;
|
||||
fr3.x = x;
|
||||
fr3.y = y + 1.f;
|
||||
fr4.x = x + 1.f;
|
||||
fr4.y = y + 1.f;
|
||||
|
||||
inputs[0][0] = fr1;
|
||||
inputs[1][0] = fr2;
|
||||
inputs[2][0] = fr3;
|
||||
inputs[3][0] = fr4;
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
float4 vec;
|
||||
vec.x = coef->a0[0];
|
||||
vec.y = coef->a0[1];
|
||||
vec.z = coef->a0[2];
|
||||
vec.w = coef->a0[3];
|
||||
inputs[i][1] = vec;
|
||||
}
|
||||
/*printf("XXX LLVM run_vertex_shader vertices = %d, inputs = %d, attribs = %d, consts = %d\n",
|
||||
num_vertices, num_inputs, num_attribs, num_consts);*/
|
||||
//from_array(inputs, ainputs, num_vertices, num_inputs);
|
||||
@@ -243,8 +265,8 @@ int run_fragment_shader(float x, float y,
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
float4 *in = inputs[i];
|
||||
float4 *res = results[i];
|
||||
//execute_shader(res, in, consts, temps);
|
||||
to_array(dests[i], res, num_attribs);
|
||||
execute_shader(res, in, consts, temps);
|
||||
to_array(dests[i], res, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
|
||||
#include "x86/rtasm/x86sse.h"
|
||||
|
||||
#include "pipe/llvm/gallivm.h"
|
||||
|
||||
#include "sp_context.h"
|
||||
#include "sp_state.h"
|
||||
#include "sp_headers.h"
|
||||
@@ -54,6 +56,7 @@ struct quad_shade_stage
|
||||
struct tgsi_exec_machine machine;
|
||||
struct tgsi_exec_vector *inputs, *outputs;
|
||||
int colorOutSlot, depthOutSlot;
|
||||
struct gallivm_prog *llvm_prog;
|
||||
};
|
||||
|
||||
|
||||
@@ -161,20 +164,20 @@ shade_quad(
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
shade_quad_llvm(struct quad_stage *qs,
|
||||
struct quad_header *quad)
|
||||
{
|
||||
struct quad_shade_stage *qss = quad_shade_stage(qs);
|
||||
struct softpipe_context *softpipe = qs->softpipe;
|
||||
float dests[4][32][4];
|
||||
const float fx = (float) quad->x0;
|
||||
const float fy = (float) quad->y0;
|
||||
struct gallivm_prog *llvm = qss->llvm_prog;
|
||||
|
||||
|
||||
quad->mask = gallivm_fragment_shader_exec(
|
||||
llvm, fx, fy, quad->coef,
|
||||
llvm, fx, fy, dests, quad->coef,
|
||||
softpipe->mapped_constants[PIPE_SHADER_FRAGMENT],
|
||||
qss->samplers, softpipe->sampler_units);
|
||||
|
||||
@@ -185,7 +188,7 @@ shade_quad_llvm(struct quad_stage *qs,
|
||||
== TGSI_SEMANTIC_COLOR);
|
||||
memcpy(
|
||||
quad->outputs.color,
|
||||
&machine->Outputs[qss->colorOutSlot].xyzw[0].f[0],
|
||||
&dests[0][qss->colorOutSlot],
|
||||
sizeof( quad->outputs.color ) );
|
||||
}
|
||||
|
||||
@@ -194,14 +197,14 @@ shade_quad_llvm(struct quad_stage *qs,
|
||||
/* output[slot] is new Z */
|
||||
uint i;
|
||||
for (i = 0; i < 4; i++) {
|
||||
quad->outputs.depth[i] = machine->Outputs[0].xyzw[2].f[i];
|
||||
quad->outputs.depth[i] = dests[0][2][i];
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* copy input Z (which was interpolated by the executor) to output Z */
|
||||
uint i;
|
||||
for (i = 0; i < 4; i++) {
|
||||
quad->outputs.depth[i] = machine->Inputs[0].xyzw[2].f[i];
|
||||
quad->outputs.depth[i] = dests[0][2][i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +213,6 @@ shade_quad_llvm(struct quad_stage *qs,
|
||||
qs->next->run( qs->next, quad );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Per-primitive (or per-begin?) setup
|
||||
@@ -227,6 +229,7 @@ static void shade_begin(struct quad_stage *qs)
|
||||
qss->samplers[i].texture = softpipe->texture[i];
|
||||
}
|
||||
|
||||
qss->llvm_prog = softpipe->fs->llvm_prog;
|
||||
/* XXX only do this if the fragment shader changes... */
|
||||
tgsi_exec_machine_init(&qss->machine,
|
||||
softpipe->fs->shader.tokens,
|
||||
@@ -275,7 +278,11 @@ struct quad_stage *sp_quad_shade_stage( struct softpipe_context *softpipe )
|
||||
|
||||
qss->stage.softpipe = softpipe;
|
||||
qss->stage.begin = shade_begin;
|
||||
#ifdef MESA_LLVM
|
||||
qss->stage.run = shade_quad_llvm;
|
||||
#else
|
||||
qss->stage.run = shade_quad;
|
||||
#endif
|
||||
qss->stage.destroy = shade_destroy;
|
||||
|
||||
/* set TGSI sampler state that's constant */
|
||||
|
||||
Reference in New Issue
Block a user