struct gl_context *ctx;
struct gl_program *prog;
struct gl_shader_program *shader_program;
- struct gl_shader *shader;
+ struct gl_linked_shader *shader;
struct gl_shader_compiler_options *options;
int next_temp;
emit_asm(ir, TGSI_OPCODE_TRUNC, result_dst, op[0]);
break;
case ir_unop_bitcast_f2i:
- result_src = op[0];
- result_src.type = GLSL_TYPE_INT;
- break;
case ir_unop_bitcast_f2u:
- result_src = op[0];
- result_src.type = GLSL_TYPE_UINT;
+ /* Make sure we don't propagate the negate modifier to integer opcodes. */
+ if (op[0].negate)
+ emit_asm(ir, TGSI_OPCODE_MOV, result_dst, op[0]);
+ else
+ result_src = op[0];
+ result_src.type = ir->operation == ir_unop_bitcast_f2i ? GLSL_TYPE_INT :
+ GLSL_TYPE_UINT;
break;
case ir_unop_bitcast_i2f:
case ir_unop_bitcast_u2f:
ir->coordinate->accept(this);
/* Put our coords in a temp. We'll need to modify them for shadow,
- * projection, or LOD, so the only case we'd use it as is is if
+ * projection, or LOD, so the only case we'd use it as-is is if
* we're doing plain old texturing. The optimization passes on
* glsl_to_tgsi_visitor should handle cleaning up our mess in that case.
*/
*
* The bias of the y-coordinate depends on whether y-inversion takes place
* (adjY[1]) or not (adjY[0]), which is in turn dependent on whether we are
- * drawing to an FBO (causes additional inversion), and whether the the pipe
+ * drawing to an FBO (causes additional inversion), and whether the pipe
* driver origin and the requested origin differ (the latter condition is
* stored in the 'invert' variable).
*
}
if (procType == PIPE_SHADER_FRAGMENT) {
- if (program->shader->EarlyFragmentTests)
+ if (program->shader->info.EarlyFragmentTests)
ureg_property(ureg, TGSI_PROPERTY_FS_EARLY_DEPTH_STENCIL, 1);
if (proginfo->InputsRead & VARYING_BIT_POS) {
static struct gl_program *
get_mesa_program_tgsi(struct gl_context *ctx,
struct gl_shader_program *shader_program,
- struct gl_shader *shader)
+ struct gl_linked_shader *shader)
{
glsl_to_tgsi_visitor* v;
struct gl_program *prog;
GLenum target = _mesa_shader_stage_to_program(shader->Stage);
bool progress;
struct gl_shader_compiler_options *options =
- &ctx->Const.ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(shader->Type)];
+ &ctx->Const.ShaderCompilerOptions[shader->Stage];
struct pipe_screen *pscreen = ctx->st->pipe->screen;
unsigned ptarget = st_shader_stage_to_ptarget(shader->Stage);
/* Perform optimizations on the instructions in the glsl_to_tgsi_visitor. */
v->simplify_cmp();
- if (shader->Type != GL_TESS_CONTROL_SHADER &&
- shader->Type != GL_TESS_EVALUATION_SHADER)
+ if (shader->Stage != MESA_SHADER_TESS_CTRL &&
+ shader->Stage != MESA_SHADER_TESS_EVAL)
v->copy_propagate();
while (v->eliminate_dead_code());
shader->ir = NULL;
/* This must be done before the uniform storage is associated. */
- if (shader->Type == GL_FRAGMENT_SHADER &&
+ if (shader->Stage == MESA_SHADER_FRAGMENT &&
(prog->InputsRead & VARYING_BIT_POS ||
prog->SystemValuesRead & (1 << SYSTEM_VALUE_FRAG_COORD))) {
static const gl_state_index wposTransformState[STATE_LENGTH] = {
struct st_tesseval_program *sttep;
struct st_compute_program *stcp;
- switch (shader->Type) {
- case GL_VERTEX_SHADER:
+ switch (shader->Stage) {
+ case MESA_SHADER_VERTEX:
stvp = (struct st_vertex_program *)prog;
stvp->glsl_to_tgsi = v;
break;
- case GL_FRAGMENT_SHADER:
+ case MESA_SHADER_FRAGMENT:
stfp = (struct st_fragment_program *)prog;
stfp->glsl_to_tgsi = v;
break;
- case GL_GEOMETRY_SHADER:
+ case MESA_SHADER_GEOMETRY:
stgp = (struct st_geometry_program *)prog;
stgp->glsl_to_tgsi = v;
break;
- case GL_TESS_CONTROL_SHADER:
+ case MESA_SHADER_TESS_CTRL:
sttcp = (struct st_tessctrl_program *)prog;
sttcp->glsl_to_tgsi = v;
break;
- case GL_TESS_EVALUATION_SHADER:
+ case MESA_SHADER_TESS_EVAL:
sttep = (struct st_tesseval_program *)prog;
sttep->glsl_to_tgsi = v;
break;
- case GL_COMPUTE_SHADER:
+ case MESA_SHADER_COMPUTE:
stcp = (struct st_compute_program *)prog;
stcp->glsl_to_tgsi = v;
break;
static struct gl_program *
get_mesa_program(struct gl_context *ctx,
struct gl_shader_program *shader_program,
- struct gl_shader *shader)
+ struct gl_linked_shader *shader)
{
struct pipe_screen *pscreen = ctx->st->pipe->screen;
unsigned ptarget = st_shader_stage_to_ptarget(shader->Stage);
pscreen->get_shader_param(pscreen, ptarget, PIPE_SHADER_CAP_PREFERRED_IR);
if (preferred_ir == PIPE_SHADER_IR_NIR) {
/* TODO only for GLSL VS/FS for now: */
- switch (shader->Type) {
- case GL_VERTEX_SHADER:
- case GL_FRAGMENT_SHADER:
+ switch (shader->Stage) {
+ case MESA_SHADER_VERTEX:
+ case MESA_SHADER_FRAGMENT:
return st_nir_get_mesa_program(ctx, shader_program, shader);
default:
break;
extern "C" {
-static void
-st_dump_program_for_shader_db(struct gl_context *ctx,
- struct gl_shader_program *prog)
-{
- /* Dump only successfully compiled and linked shaders to the specified
- * file. This is for shader-db.
- *
- * These options allow some pre-processing of shaders while dumping,
- * because some apps have ill-formed shaders.
- */
- const char *dump_filename = os_get_option("ST_DUMP_SHADERS");
- const char *insert_directives = os_get_option("ST_DUMP_INSERT");
-
- if (dump_filename && prog->Name != 0) {
- FILE *f = fopen(dump_filename, "a");
-
- if (f) {
- for (unsigned i = 0; i < prog->NumShaders; i++) {
- const struct gl_shader *sh = prog->Shaders[i];
- const char *source;
- bool skip_version = false;
-
- if (!sh)
- continue;
-
- source = sh->Source;
-
- /* This string mustn't be changed. shader-db uses it to find
- * where the shader begins.
- */
- fprintf(f, "GLSL %s shader %d source for linked program %d:\n",
- _mesa_shader_stage_to_string(sh->Stage),
- i, prog->Name);
-
- /* Dump the forced version if set. */
- if (ctx->Const.ForceGLSLVersion) {
- fprintf(f, "#version %i\n", ctx->Const.ForceGLSLVersion);
- skip_version = true;
- }
-
- /* Insert directives (optional). */
- if (insert_directives) {
- if (!ctx->Const.ForceGLSLVersion && prog->Version)
- fprintf(f, "#version %i\n", prog->Version);
- fprintf(f, "%s\n", insert_directives);
- skip_version = true;
- }
-
- if (skip_version && strncmp(source, "#version ", 9) == 0) {
- const char *next_line = strstr(source, "\n");
-
- if (next_line)
- source = next_line + 1;
- else
- continue;
- }
-
- fprintf(f, "%s", source);
- fprintf(f, "\n");
- }
- fclose(f);
- }
- }
-}
-
/**
* Link a shader.
* Called via ctx->Driver.LinkShader()
bool progress;
exec_list *ir = prog->_LinkedShaders[i]->ir;
- gl_shader_stage stage = _mesa_shader_enum_to_shader_stage(prog->_LinkedShaders[i]->Type);
+ gl_shader_stage stage = prog->_LinkedShaders[i]->Stage;
const struct gl_shader_compiler_options *options =
&ctx->Const.ShaderCompilerOptions[stage];
unsigned ptarget = st_shader_stage_to_ptarget(stage);
(have_dround ? 0 : DOPS_TO_DFRAC) |
(options->EmitNoPow ? POW_TO_EXP2 : 0) |
(!ctx->Const.NativeIntegers ? INT_DIV_TO_MUL_RCP : 0) |
- (options->EmitNoSat ? SAT_TO_CLAMP : 0));
+ (options->EmitNoSat ? SAT_TO_CLAMP : 0) |
+ /* Assume that if ARB_gpu_shader5 is not supported
+ * then all of the extended integer functions need
+ * lowering. It may be necessary to add some caps
+ * for individual instructions.
+ */
+ (!ctx->Extensions.ARB_gpu_shader5
+ ? BIT_COUNT_TO_MATH |
+ EXTRACT_TO_SHIFTS |
+ INSERT_TO_SHIFTS |
+ REVERSE_TO_SHIFTS |
+ FIND_LSB_TO_FLOAT_CAST |
+ FIND_MSB_TO_FLOAT_CAST |
+ IMUL_HIGH_TO_MUL
+ : 0));
do_vec_index_to_cond_assign(ir);
lower_vector_insert(ir, true);
_mesa_reference_program(ctx, &linked_prog, NULL);
}
- st_dump_program_for_shader_db(ctx, prog);
return GL_TRUE;
}