mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-16 02:10:25 +01:00
Initial r5xx fragment program compiler support.
Includes fallback shader and a handful of working opcodes.
This commit is contained in:
parent
c02d1863d1
commit
6e96ea535a
6 changed files with 326 additions and 2222 deletions
|
|
@ -774,6 +774,54 @@ struct r300_fragment_program {
|
|||
GLuint optimization;
|
||||
};
|
||||
|
||||
struct r500_fragment_program {
|
||||
struct gl_fragment_program mesa_program;
|
||||
|
||||
GLcontext *ctx;
|
||||
GLboolean translated;
|
||||
GLboolean error;
|
||||
struct r300_pfs_compile_state *cs;
|
||||
|
||||
struct {
|
||||
GLuint inst0;
|
||||
GLuint inst1;
|
||||
GLuint inst2;
|
||||
GLuint inst3;
|
||||
GLuint inst4;
|
||||
GLuint inst5;
|
||||
} inst[512];
|
||||
/* TODO: This is magic! */
|
||||
|
||||
struct {
|
||||
int tex_offset;
|
||||
int tex_end;
|
||||
int alu_offset;
|
||||
int alu_end;
|
||||
int flags;
|
||||
} node[4];
|
||||
int cur_node;
|
||||
int first_node_has_tex;
|
||||
|
||||
int alu_offset;
|
||||
int alu_end;
|
||||
int tex_offset;
|
||||
int tex_end;
|
||||
|
||||
/* Hardware constants.
|
||||
* Contains a pointer to the value. The destination of the pointer
|
||||
* is supposed to be updated when GL state changes.
|
||||
* Typically, this is either a pointer into
|
||||
* gl_program_parameter_list::ParameterValues, or a pointer to a
|
||||
* global constant (e.g. for sin/cos-approximation)
|
||||
*/
|
||||
const GLfloat *constant[PFS_NUM_CONST_REGS];
|
||||
int const_nr;
|
||||
|
||||
int max_temp_idx;
|
||||
|
||||
GLuint optimization;
|
||||
};
|
||||
|
||||
#define R300_MAX_AOS_ARRAYS 16
|
||||
|
||||
#define REG_COORDS 0
|
||||
|
|
|
|||
|
|
@ -2217,6 +2217,7 @@ static void update_params(struct r300_fragment_program *fp)
|
|||
void r300TranslateFragmentShader(r300ContextPtr r300,
|
||||
struct r300_fragment_program *fp)
|
||||
{
|
||||
|
||||
struct r300_pfs_compile_state *cs = NULL;
|
||||
|
||||
if (!fp->translated) {
|
||||
|
|
|
|||
|
|
@ -334,13 +334,26 @@ static GLboolean r300RunRender(GLcontext * ctx,
|
|||
static int r300Fallback(GLcontext * ctx)
|
||||
{
|
||||
r300ContextPtr r300 = R300_CONTEXT(ctx);
|
||||
struct r300_fragment_program *fp = (struct r300_fragment_program *)
|
||||
/* Do we need to use new-style shaders?
|
||||
* Also is there a better way to do this? */
|
||||
if (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) {
|
||||
struct r500_fragment_program *fp = (struct r500_fragment_program *)
|
||||
(char *)ctx->FragmentProgram._Current;
|
||||
|
||||
if (fp) {
|
||||
if (!fp->translated)
|
||||
r300TranslateFragmentShader(r300, fp);
|
||||
FALLBACK_IF(!fp->translated);
|
||||
if (fp) {
|
||||
if (!fp->translated) {
|
||||
r500TranslateFragmentShader(r300, fp);
|
||||
FALLBACK_IF(!fp->translated);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
struct r300_fragment_program *fp = (struct r300_fragment_program *)
|
||||
(char *)ctx->FragmentProgram._Current;
|
||||
if (fp) {
|
||||
if (!fp->translated) {
|
||||
r300TranslateFragmentShader(r300, fp);
|
||||
FALLBACK_IF(!fp->translated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FALLBACK_IF(ctx->RenderMode != GL_RENDER);
|
||||
|
|
|
|||
|
|
@ -2315,15 +2315,32 @@ static void r300SetupPixelShader(r300ContextPtr rmesa)
|
|||
static void r500SetupPixelShader(r300ContextPtr rmesa)
|
||||
{
|
||||
GLcontext *ctx = rmesa->radeon.glCtx;
|
||||
struct r300_fragment_program *fp = (struct r300_fragment_program *)
|
||||
struct r500_fragment_program *fp = (struct r500_fragment_program *)
|
||||
(char *)ctx->FragmentProgram._Current;
|
||||
int i, k;
|
||||
|
||||
if (!fp) /* should only happenen once, just after context is created */
|
||||
if (!fp) /* should only happen once, just after context is created */
|
||||
return;
|
||||
|
||||
r500TranslateFragmentShader(rmesa, fp);
|
||||
if (!fp->translated) {
|
||||
fprintf(stderr, "%s: No valid fragment shader, exiting\n",
|
||||
__FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
/* emit the standard zero shader */
|
||||
R300_STATECHANGE(rmesa, r500fp);
|
||||
/* Moar magic... */
|
||||
for (i = 0; i < fp->cs->nrslots; i++) {
|
||||
rmesa->hw.r500fp.cmd[i*6+1] = fp->inst[i].inst0;
|
||||
rmesa->hw.r500fp.cmd[i*6+2] = fp->inst[i].inst1;
|
||||
rmesa->hw.r500fp.cmd[i*6+3] = fp->inst[i].inst2;
|
||||
rmesa->hw.r500fp.cmd[i*6+4] = fp->inst[i].inst3;
|
||||
rmesa->hw.r500fp.cmd[i*6+5] = fp->inst[i].inst4;
|
||||
rmesa->hw.r500fp.cmd[i*6+6] = fp->inst[i].inst5;
|
||||
}
|
||||
#if 0
|
||||
i = 1;
|
||||
rmesa->hw.r500fp.cmd[i++] = 0x7808;
|
||||
rmesa->hw.r500fp.cmd[i++] = R500_TEX_ID(0) | R500_TEX_INST_LD | R500_TEX_SEM_ACQUIRE | R500_TEX_IGNORE_UNCOVERED;
|
||||
|
|
@ -2383,8 +2400,9 @@ static void r500SetupPixelShader(r300ContextPtr rmesa)
|
|||
R500_ALU_RGBA_G_SWIZ_0 |
|
||||
R500_ALU_RGBA_B_SWIZ_0 |
|
||||
R500_ALU_RGBA_A_SWIZ_0;
|
||||
#endif
|
||||
|
||||
bump_r500fp_count(rmesa->hw.r500fp.cmd, 12);
|
||||
bump_r500fp_count(rmesa->hw.r500fp.cmd, i * 6);
|
||||
|
||||
R300_STATECHANGE(rmesa, r500fp_const);
|
||||
for (i = 0; i < fp->const_nr; i++) {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -96,9 +96,7 @@ typedef struct r300_fragment_program_swizzle {
|
|||
#define DRI_CONF_FP_OPTIMIZATION_SPEED 0
|
||||
#define DRI_CONF_FP_OPTIMIZATION_QUALITY 1
|
||||
|
||||
struct r300_fragment_program;
|
||||
|
||||
extern void r300TranslateFragmentShader(r300ContextPtr r300,
|
||||
struct r300_fragment_program *fp);
|
||||
extern void r500TranslateFragmentShader(r300ContextPtr r300,
|
||||
struct r500_fragment_program *fp);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue