Lines Matching refs:shader

88         ERR("Failed to allocate %u bytes for shader source.\n", source_size);
111 static const char *arb_get_helper_value(enum wined3d_shader_type shader, enum arb_helper_value value)
113 if (shader == WINED3D_SHADER_TYPE_GEOMETRY)
119 if (shader == WINED3D_SHADER_TYPE_PIXEL)
143 FIXME("Unmanaged %s shader helper constant requested: %u\n",
144 shader == WINED3D_SHADER_TYPE_PIXEL ? "pixel" : "vertex", value);
381 * some immediate values into the shader. */
394 static unsigned int shader_arb_load_constantsF(const struct wined3d_shader *shader,
415 if (target_type == GL_FRAGMENT_PROGRAM_ARB && shader->reg_maps.shader_version.major == 1)
484 if (shader->load_local_constsF)
488 LIST_FOR_EACH_ENTRY(lconst, &shader->constantsF, struct wined3d_shader_lconst, entry)
497 LIST_FOR_EACH_ENTRY(lconst, &shader->constantsF, struct wined3d_shader_lconst, entry)
504 return ret; /* The loaded immediate constants need reloading for the next shader */
678 TRACE("bool/integer vertex shader constants potentially modified, forcing shader reselection.\n");
686 TRACE("bool/integer pixel shader constants potentially modified, forcing shader reselection.\n");
709 /* Load DirectX 9 float constants for vertex shader */
721 /* Load DirectX 9 float constants for pixel shader */
742 /* We don't want shader constant dirtification to be an O(contexts), so just dirtify the active
755 /* We don't want shader constant dirtification to be an O(contexts), so just dirtify the active
775 static void shader_generate_arb_declarations(const struct wined3d_shader *shader,
792 * subtract one from the number of constants. If the shader uses indirect addressing,
805 const struct arb_vshader_private *shader_data = shader->backend_data;
821 for (i = 0; i < shader->limits.constant_float; ++i)
872 if (!shader->load_local_constsF)
874 LIST_FOR_EACH_ENTRY(lconst, &shader->constantsF, struct wined3d_shader_lconst, entry)
885 * local constants), make sure the shader doesn't violate the env constant limit
897 max_constantsF = min(max_constantsF, shader->limits.constant_float);
915 if (!shader_constant_is_local(shader, i) && (reg_maps->constf[idx] & mask))
1011 const struct wined3d_shader *shader = ins->ctx->shader;
1050 ERR("Pixel shader input register out of bounds: %u\n", idx);
1075 * colors. This needs either a pipeline replacement to make the vertex shader feed
1080 FIXME("Non-vertex shader varying input with indirect addressing\n");
1099 ERR("Pixel shader input register out of bounds: %u\n", reg->idx[0].offset);
1116 const struct arb_vshader_private *shader_data = shader->backend_data;
1395 const struct wined3d_shader *shader;
1399 /* D3D vertex shader sampler IDs are vertex samplers(0-3), not global d3d samplers */
1408 shader = ins->ctx->shader;
1409 device = shader->device;
1793 const struct wined3d_shader *shader = ins->ctx->shader;
1806 const struct arb_vshader_private *shader_data = shader->backend_data;
1845 const struct arb_vshader_private *shader_data = shader->backend_data;
1868 if (ctx->ps_post_process && shader->u.ps.color0_mov)
1923 * or pass in any temporary register(in shader phase 2)
3177 /* The D3DRS_FOGTABLEMODE render state defines if the shader-generated fog coord is used
3180 * the shader, it is set to 0.0(fully fogged, since start = 1.0, end = 0.0)
3282 const struct wined3d_shader *shader = ins->ctx->shader;
3289 if (priv->in_main_func) vshader_add_footer(priv, shader->backend_data,
3489 static const DWORD *find_loop_control_values(const struct wined3d_shader *shader, DWORD idx)
3493 LIST_FOR_EACH_ENTRY(constant, &shader->constantsI, struct wined3d_shader_lconst, entry)
3503 static void init_ps_input(const struct wined3d_shader *shader,
3512 const struct wined3d_shader_signature_element *sig = shader->input_signature;
3525 * we'd either need a replacement shader that can load other attribs like BINORMAL, or
3526 * load the texcoord attrib pointers to match the pixel shader signature
3586 static GLuint shader_arb_generate_pshader(const struct wined3d_shader *shader,
3590 const struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
3591 const DWORD *function = shader->function;
3598 struct arb_pshader_private *shader_priv = shader->backend_data;
3610 || (shader->u.ps.color0_mov && i == shader->u.ps.color0_reg)
3643 /* Create the hw ARB shader */
3648 init_ps_input(shader, args, &priv_ctx);
3655 * and it slows down the shader execution noticeably(about 5%). Usually our instruction emulation
3682 /* This is an error - either we're advertising the wrong shader version, or aren't enforcing some
3685 ERR("The shader requires instructions that are not available in plain GL_ARB_fragment_program\n");
3721 * unused temps away(but occupies them for the whole shader if they're used once). Always
3741 if (shader->u.ps.color0_mov)
3743 sprintf(fragcolor, "R%u", shader->u.ps.color0_reg);
3766 shader_generate_arb_declarations(shader, reg_maps, buffer, gl_info, NULL, &priv_ctx);
3782 * 8 shader constants, 8 bump matrices and 8 luminance parameters and are perfectly fine. (No NP2 fixup on bumpmapped
3786 * shaders in newer shader models. Since the bump env parameters have to share their space with NP2 fixup constants,
3787 * their location is shader dependent anyway and they cannot be loaded globally.
3806 const DWORD *control_values = find_loop_control_values(shader, i);
3849 * shader compilation errors and the subsequent errors when drawing with this shader. */
3867 FIXME("No free constant found to load NP2 fixup data into shader. "
3886 shader_generate_main(shader, buffer, reg_maps, function, &priv_ctx);
3904 TRACE("Creating a hw pixel shader, prg=%d\n", retval);
3907 TRACE("Created hw pixel shader, prg=%d\n", retval);
3999 static void init_output_registers(const struct wined3d_shader *shader,
4024 TRACE("Pixel shader uses builtin varyings\n");
4035 for (i = 0; i < (sizeof(shader->output_signature) / sizeof(*shader->output_signature)); ++i)
4037 semantic_name = shader->output_signature[i].semantic_name;
4043 if (!shader->output_signature[i].semantic_idx) priv_ctx->vs_output[i] = "TMP_OUT";
4049 if (!shader->output_signature[i].semantic_idx) priv_ctx->vs_output[i] = "result.pointsize";
4054 TRACE("o%u is result.color.?, idx %u\n", i, shader->output_signature[i].semantic_idx);
4055 if (!shader->output_signature[i].semantic_idx)
4057 else if (shader->output_signature[i].semantic_idx == 1)
4063 TRACE("o%u is %s\n", i, texcoords[shader->output_signature[i].semantic_idx]);
4064 if (shader->output_signature[i].semantic_idx >= 8) priv_ctx->vs_output[i] = "TA";
4065 else priv_ctx->vs_output[i] = texcoords[shader->output_signature[i].semantic_idx];
4070 if (shader->output_signature[i].semantic_idx > 0) priv_ctx->vs_output[i] = "TA";
4081 TRACE("Pixel shader uses declared varyings\n");
4102 * Don't care about POSITION and PSIZE here - this is a builtin vertex shader, position goes
4133 for (i = 0; i < (sizeof(shader->output_signature) / sizeof(*shader->output_signature)); ++i)
4137 semantic_name = shader->output_signature[i].semantic_name;
4141 && !shader->output_signature[i].semantic_idx)
4147 && !shader->output_signature[i].semantic_idx)
4158 && ps_input_sig[j].semantic_idx == shader->output_signature[i].semantic_idx)
4173 static GLuint shader_arb_generate_vshader(const struct wined3d_shader *shader,
4178 const struct arb_vshader_private *shader_data = shader->backend_data;
4179 const struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
4180 struct shader_arb_priv *priv = shader->device->shader_priv;
4181 const DWORD *function = shader->function;
4191 init_output_registers(shader, ps_input_sig, &priv_ctx, compiled);
4193 /* Create the hw ARB shader */
4233 shader_generate_arb_declarations(shader, reg_maps, buffer, gl_info,
4241 const DWORD *control_values = find_loop_control_values(shader, i);
4264 * a replacement shader depend on the texcoord.w being set properly.
4289 /* The shader starts with the main function */
4292 shader_generate_main(shader, buffer, reg_maps, function, &priv_ctx);
4302 TRACE("Creating a hw vertex shader, prg=%d\n", ret);
4305 TRACE("Created hw vertex shader, prg=%d\n", ret);
4332 static struct arb_ps_compiled_shader *find_arb_pshader(struct wined3d_shader *shader,
4335 struct wined3d_device *device = shader->device;
4345 if (!shader->backend_data)
4349 shader->backend_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data));
4350 shader_data = shader->backend_data;
4351 shader_data->clamp_consts = shader->reg_maps.shader_version.major == 1;
4353 if (shader->reg_maps.shader_version.major < 3)
4356 shader_data->input_signature_idx = find_input_signature(priv, shader->input_signature);
4361 shader_data->clipplane_emulation = shader_find_free_input_register(&shader->reg_maps,
4366 shader_data = shader->backend_data;
4368 /* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2),
4378 TRACE("No matching GL shader found, compiling a new shader\n");
4400 pixelshader_update_samplers(shader, args->super.tex_types);
4404 ERR("Failed to initialize shader buffer.\n");
4408 ret = shader_arb_generate_pshader(shader, gl_info, &buffer, args,
4429 static struct arb_vs_compiled_shader *find_arb_vshader(struct wined3d_shader *shader,
4433 struct wined3d_device *device = shader->device;
4443 if (!shader->backend_data)
4445 const struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
4447 shader->backend_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data));
4448 shader_data = shader->backend_data;
4465 shader_data = shader->backend_data;
4467 /* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2),
4479 TRACE("No matching GL shader found, compiling a new shader\n");
4504 ERR("Failed to initialize shader buffer.\n");
4508 ret = shader_arb_generate_vshader(shader, gl_info, &buffer, args,
4518 const struct wined3d_context *context, const struct wined3d_shader *shader,
4526 find_ps_compile_args(state, shader, &args->super);
4529 args->bools = shader->reg_maps.local_bool_consts;
4539 * duplicate the shader than have a no-op KIL instruction in every shader
4549 int_skip = ~shader->reg_maps.integer_constants | shader->reg_maps.local_int_consts;
4574 const struct wined3d_context *context, const struct wined3d_shader *shader,
4577 struct wined3d_device *device = shader->device;
4584 find_vs_compile_args(state, shader, &args->super);
4613 args->clip.boolclip.bools = shader->reg_maps.local_bool_consts;
4627 int_skip = ~shader->reg_maps.integer_constants | shader->reg_maps.local_int_consts;
4660 /* Deal with pixel shaders first so the vertex shader arg function has the input signature ready */
4667 TRACE("Using pixel shader %p.\n", ps);
4687 * a 1.x and newer shader, reload the first 8 constants
4717 * function replacement shader. */
4732 TRACE("Using vertex shader %p\n", vs);
4736 * current pixel shader. It's maybe not the shader where the signature came from, but it
4864 static void shader_arb_destroy(struct wined3d_shader *shader)
4866 struct wined3d_device *device = shader->device;
4869 if (shader_is_pshader_version(shader->reg_maps.shader_version.type))
4871 struct arb_pshader_private *shader_data = shader->backend_data;
4874 if(!shader_data) return; /* This can happen if a shader was never compiled */
4891 shader->backend_data = NULL;
4895 struct arb_vshader_private *shader_data = shader->backend_data;
4898 if(!shader_data) return; /* This can happen if a shader was never compiled */
4915 shader->backend_data = NULL;
5065 TRACE("Hardware vertex shader version 3.0 enabled (NV_VERTEX_PROGRAM3)\n");
5069 /* Shader Model 2.0 requires at least 256 vertex shader constants */
5071 TRACE("Hardware vertex shader version 2.0 enabled (ARB_PROGRAM)\n");
5076 TRACE("Hardware vertex shader version 1.1 enabled (ARB_PROGRAM)\n");
5104 TRACE("Hardware pixel shader version 3.0 enabled (NV_FRAGMENT_PROGRAM2)\n");
5108 /* Shader Model 2.0 requires at least 32 pixel shader constants */
5110 TRACE("Hardware pixel shader version 2.0 enabled (ARB_PROGRAM)\n");
5115 TRACE("Hardware pixel shader version 1.4 enabled (ARB_PROGRAM)\n");
5219 /* WINED3DSIH_IF */ NULL /* Hardcoded into the shader */,
5292 const struct wined3d_shader *shader, DWORD idx)
5304 LIST_FOR_EACH_ENTRY(constant, &shader->constantsB, struct wined3d_shader_lconst, entry)
5323 const struct wined3d_shader *shader, UINT idx, struct wined3d_shader_loop_control *loop_control)
5328 /* Integer constants can either be a local constant, or they can be stored in the shader
5334 LIST_FOR_EACH_ENTRY(constant, &shader->constantsI, struct wined3d_shader_lconst, entry)
5370 FIXME("Unhandled shader type %#x.\n", reg_maps->shader_version.type);
5489 const struct wined3d_shader *shader = ins->ctx->shader;
5520 get_loop_control_const(ins, shader, ins->src[0].reg.idx[0].offset, &control_frame->loop_control);
5617 bool_const = get_bool_const(ins, shader, ins->src[0].reg.idx[0].offset);
5654 /* In case of an ifc, generate a HW shader instruction */
5671 /* In case of an ifc, generate a HW shader instruction */
5735 GLuint shader;
5757 /* Share private data between the shader backend and the pipeline
5759 * figure out whether ARBfp should be disabled if no pixel shader is bound
5784 GL_EXTCALL(glDeleteProgramsARB(1, &entry_arb->shader));
5785 checkGLcall("glDeleteProgramsARB(1, &entry_arb->shader)");
5847 /* Don't load the parameter if we're using an arbfp pixel shader,
5872 /* Don't load the parameter if we're using an arbfp pixel shader, otherwise we'll overwrite
5908 /* The pixel shader has to know the bump env matrix. Do a constants
5914 /* Exit now, don't set the bumpmat below, otherwise we may overwrite pixel shader constants */
5944 /* The pixel shader has to know the luminance offset. Do a constants
5950 /* Exit now, don't set the bumpmat below, otherwise we may overwrite pixel shader constants */
6161 /* Those are handled in the first pass of the shader(generation pass 1 and 2) already */
6255 ERR("Failed to initialize shader buffer.\n");
6383 /* Generate the main shader */
6452 /* Generate the shader */
6496 * pixel shader constants. */
6513 /* Find or create a shader implementing the fixed function pipeline
6526 new_desc->shader = gen_arbfp_ffp_shader(&settings, gl_info);
6528 TRACE("Allocated fixed function replacement shader descriptor %p\n", new_desc);
6536 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, desc->shader));
6537 checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, desc->shader)");
6538 priv->current_fprogram_id = desc->shader;
6543 * pixel shader constants. */
7048 GLenum shader;
7055 ERR("Failed to initialize shader buffer.\n");
7059 GL_EXTCALL(glGenProgramsARB(1, &shader));
7060 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader));
7061 if (!shader)
7099 priv->p8_rect_shader = shader;
7101 priv->p8_2d_shader = shader;
7105 return shader;
7155 GLenum shader;
7163 ERR("Failed to initialize shader buffer.\n");
7167 GL_EXTCALL(glGenProgramsARB(1, &shader));
7168 checkGLcall("GL_EXTCALL(glGenProgramsARB(1, &shader))");
7169 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader));
7170 checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader)");
7171 if (!shader)
7207 * is filtering. This would have to be emulated completely in the shader, reading
7284 if (textype == GL_TEXTURE_RECTANGLE_ARB) priv->yuy2_rect_shader = shader;
7285 else priv->yuy2_2d_shader = shader;
7289 if (textype == GL_TEXTURE_RECTANGLE_ARB) priv->uyvy_rect_shader = shader;
7290 else priv->uyvy_2d_shader = shader;
7294 if (textype == GL_TEXTURE_RECTANGLE_ARB) priv->yv12_rect_shader = shader;
7295 else priv->yv12_2d_shader = shader;
7301 return shader;
7307 GLenum shader;
7330 /* Don't bother setting up a shader for unconverted formats */
7341 shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->yuy2_rect_shader : priv->yuy2_2d_shader;
7345 shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->uyvy_rect_shader : priv->uyvy_2d_shader;
7349 shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->yv12_rect_shader : priv->yv12_2d_shader;
7353 shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->p8_rect_shader : priv->p8_2d_shader;
7354 if (!shader) shader = gen_p8_shader(priv, gl_info, textype);
7360 FIXME("Unsupported complex fixup %#x, not setting a shader\n", fixup);
7366 if (!shader) shader = gen_yuv_shader(priv, gl_info, fixup, textype);
7370 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader));
7371 checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader)");