diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index d82d24c1c6a..90062b8b000 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -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; diff --git a/dlls/wined3d/pixelshader.c b/dlls/wined3d/pixelshader.c index 245c6b0142f..8b2977bec4d 100644 --- a/dlls/wined3d/pixelshader.c +++ b/dlls/wined3d/pixelshader.c @@ -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}, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 1cfd6223db0..da4a90c2608 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -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 */