Commit 3d3369a7 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: d3d ignores the sign of the input value in the log instruction.

parent 6dc11616
......@@ -1346,6 +1346,27 @@ void shader_glsl_pow(SHADER_OPCODE_ARG *arg) {
}
}
/* Process the WINED3DSIO_LOG instruction in GLSL (dst = log2(|src0|))
* Src0 is a scalar. Note that D3D uses the absolute of src0, while
* GLSL uses the value as-is. */
void shader_glsl_log(SHADER_OPCODE_ARG *arg) {
SHADER_BUFFER *buffer = arg->buffer;
glsl_src_param_t src0_param;
DWORD dst_write_mask;
size_t dst_size;
dst_write_mask = shader_glsl_append_dst(buffer, arg);
dst_size = shader_glsl_get_write_mask_size(dst_write_mask);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], WINED3DSP_WRITEMASK_0, &src0_param);
if (dst_size > 1) {
shader_addline(buffer, "vec%d(log2(abs(%s))));\n", dst_size, src0_param.param_str);
} else {
shader_addline(buffer, "log2(abs(%s)));\n", src0_param.param_str);
}
}
/* Map the opcode 1-to-1 to the GL code (arg->dst = instruction(src0, src1, ...) */
void shader_glsl_map2gl(SHADER_OPCODE_ARG* arg) {
CONST SHADER_OPCODE* curOpcode = arg->opcode;
......
......@@ -167,7 +167,7 @@ CONST SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins[] = {
{WINED3DSIO_SGE, "sge", "SGE", 1, 3, pshader_hw_map2gl, shader_glsl_compare, 0, 0},
{WINED3DSIO_ABS, "abs", "ABS", 1, 2, pshader_hw_map2gl, shader_glsl_map2gl, 0, 0},
{WINED3DSIO_EXP, "exp", "EX2", 1, 2, pshader_hw_map2gl, shader_glsl_map2gl, 0, 0},
{WINED3DSIO_LOG, "log", "LG2", 1, 2, pshader_hw_map2gl, shader_glsl_map2gl, 0, 0},
{WINED3DSIO_LOG, "log", "LG2", 1, 2, pshader_hw_map2gl, shader_glsl_log, 0, 0},
{WINED3DSIO_EXPP, "expp", "EXP", 1, 2, pshader_hw_map2gl, shader_glsl_expp, 0, 0},
{WINED3DSIO_LOGP, "logp", "LOG", 1, 2, pshader_hw_map2gl, shader_glsl_map2gl, 0, 0},
{WINED3DSIO_DST, "dst", "DST", 1, 3, pshader_hw_map2gl, shader_glsl_dst, 0, 0},
......
......@@ -1839,6 +1839,7 @@ extern void shader_glsl_call(SHADER_OPCODE_ARG* arg);
extern void shader_glsl_callnz(SHADER_OPCODE_ARG* arg);
extern void shader_glsl_label(SHADER_OPCODE_ARG* arg);
extern void shader_glsl_pow(SHADER_OPCODE_ARG* arg);
extern void shader_glsl_log(SHADER_OPCODE_ARG* arg);
extern void shader_glsl_texldl(SHADER_OPCODE_ARG* arg);
/** GLSL Pixel Shader Prototypes */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment