Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/wined3d/glsl_shader.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index a99762b151f..86259ae4755 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -5131,20 +5131,20 @@ static void shader_glsl_default(const struct wined3d_shader_instruction *ins) shader_addline(ins->ctx->buffer, "default:\n"); }
-static void shader_glsl_generate_conditional_op(const struct wined3d_shader_instruction *ins, - const char *op) +static void shader_glsl_generate_condition(const struct wined3d_shader_instruction *ins) { struct glsl_src_param src_param; const char *condition;
condition = ins->flags == WINED3D_SHADER_CONDITIONAL_OP_NZ ? "bool" : "!bool"; shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_0, &src_param); - shader_addline(ins->ctx->buffer, "if (%s(%s)) %s\n", condition, src_param.param_str, op); + shader_addline(ins->ctx->buffer, "if (%s(%s))\n", condition, src_param.param_str); }
static void shader_glsl_if(const struct wined3d_shader_instruction *ins) { - shader_glsl_generate_conditional_op(ins, "{"); + shader_glsl_generate_condition(ins); + shader_addline(ins->ctx->buffer, "{\n"); }
static void shader_glsl_ifc(const struct wined3d_shader_instruction *ins) @@ -5203,15 +5203,29 @@ static void shader_glsl_conditional_op(const struct wined3d_shader_instruction *
switch (ins->handler_idx) { - case WINED3DSIH_BREAKP: op = "break;"; break; - case WINED3DSIH_CONTINUEP: op = "continue;"; break; - case WINED3DSIH_RETP: op = "return;"; break; + case WINED3DSIH_BREAKP: + op = "break;"; + break; + case WINED3DSIH_CONTINUEP: + op = "continue;"; + break; + case WINED3DSIH_RETP: + op = "return;"; + break; default: ERR("Unhandled opcode %#x.\n", ins->handler_idx); return; }
- shader_glsl_generate_conditional_op(ins, op); + shader_glsl_generate_condition(ins); + if (ins->handler_idx == WINED3DSIH_RETP) + { + shader_addline(ins->ctx->buffer, "{\n"); + shader_glsl_generate_shader_epilogue(ins->ctx); + } + shader_addline(ins->ctx->buffer, " %s\n", op); + if (ins->handler_idx == WINED3DSIH_RETP) + shader_addline(ins->ctx->buffer, "}\n"); }
static void shader_glsl_continue(const struct wined3d_shader_instruction *ins) @@ -6764,7 +6778,8 @@ static void shader_glsl_texkill(const struct wined3d_shader_instruction *ins) { if (ins->ctx->reg_maps->shader_version.major >= 4) { - shader_glsl_generate_conditional_op(ins, "discard;"); + shader_glsl_generate_condition(ins); + shader_addline(ins->ctx->buffer, " discard;\n"); } else {
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- This is what eventually came out of trying to rework https://source.winehq.org/patches/data/147005 to use shader_glsl_sprintf_cast(). Tests seem to still pass.
Aside from that, I don't know if there is any plan to use the values I'm dropping in this patch in the future. If so, just shoot this patch (and the next) down.
dlls/wined3d/glsl_shader.c | 12 ----------- dlls/wined3d/shader.c | 12 ----------- dlls/wined3d/shader_sm4.c | 48 ++++++++++++++++++------------------------ dlls/wined3d/wined3d_private.h | 6 ------ 4 files changed, 21 insertions(+), 57 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 86259ae4755..ffe0c2d7e14 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -2523,8 +2523,6 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont switch (reg_maps->resource_info[entry->resource_idx].data_type) { case WINED3D_DATA_FLOAT: - case WINED3D_DATA_UNORM: - case WINED3D_DATA_SNORM: sampler_type_prefix = ""; break;
@@ -2641,8 +2639,6 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont switch (reg_maps->uav_resource_info[i].data_type) { case WINED3D_DATA_FLOAT: - case WINED3D_DATA_UNORM: - case WINED3D_DATA_SNORM: image_type_prefix = ""; read_format = "r32f"; break; @@ -3093,8 +3089,6 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register * case WINED3D_DATA_INT: sprintf(register_name, "%#x", reg->u.immconst_data[0]); break; - case WINED3D_DATA_RESOURCE: - case WINED3D_DATA_SAMPLER: case WINED3D_DATA_UINT: sprintf(register_name, "%#xu", reg->u.immconst_data[0]); break; @@ -3129,8 +3123,6 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register * reg->u.immconst_data[0], reg->u.immconst_data[1], reg->u.immconst_data[2], reg->u.immconst_data[3]); break; - case WINED3D_DATA_RESOURCE: - case WINED3D_DATA_SAMPLER: case WINED3D_DATA_UINT: sprintf(register_name, "uvec4(%#xu, %#xu, %#xu, %#xu)", reg->u.immconst_data[0], reg->u.immconst_data[1], @@ -3342,8 +3334,6 @@ static void shader_glsl_sprintf_cast(struct wined3d_string_buffer *dst_param, co case WINED3D_DATA_INT: string_buffer_sprintf(dst_param, "floatBitsToInt(%s)", src_param); return; - case WINED3D_DATA_RESOURCE: - case WINED3D_DATA_SAMPLER: case WINED3D_DATA_UINT: string_buffer_sprintf(dst_param, "floatBitsToUint(%s)", src_param); return; @@ -3457,8 +3447,6 @@ static DWORD shader_glsl_append_dst_ext(struct wined3d_string_buffer *buffer, shader_addline(buffer, "%s%s = %sintBitsToFloat(", glsl_dst.reg_name, glsl_dst.mask_str, shift_glsl_tab[dst->shift]); break; - case WINED3D_DATA_RESOURCE: - case WINED3D_DATA_SAMPLER: case WINED3D_DATA_UINT: shader_addline(buffer, "%s%s = %suintBitsToFloat(", glsl_dst.reg_name, glsl_dst.mask_str, shift_glsl_tab[dst->shift]); diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 20d4f0773dd..a2c3f00559a 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -2134,14 +2134,6 @@ static void shader_dump_decl_usage(struct wined3d_string_buffer *buffer, shader_addline(buffer, " (uint)"); break;
- case WINED3D_DATA_UNORM: - shader_addline(buffer, " (unorm)"); - break; - - case WINED3D_DATA_SNORM: - shader_addline(buffer, " (snorm)"); - break; - default: shader_addline(buffer, " (unknown)"); break; @@ -2448,8 +2440,6 @@ static void shader_dump_register(struct wined3d_string_buffer *buffer, case WINED3D_DATA_INT: shader_addline(buffer, "%d", reg->u.immconst_data[0]); break; - case WINED3D_DATA_RESOURCE: - case WINED3D_DATA_SAMPLER: case WINED3D_DATA_UINT: shader_addline(buffer, "%u", reg->u.immconst_data[0]); break; @@ -2472,8 +2462,6 @@ static void shader_dump_register(struct wined3d_string_buffer *buffer, reg->u.immconst_data[0], reg->u.immconst_data[1], reg->u.immconst_data[2], reg->u.immconst_data[3]); break; - case WINED3D_DATA_RESOURCE: - case WINED3D_DATA_SAMPLER: case WINED3D_DATA_UINT: shader_addline(buffer, "%u, %u, %u, %u", reg->u.immconst_data[0], reg->u.immconst_data[1], diff --git a/dlls/wined3d/shader_sm4.c b/dlls/wined3d/shader_sm4.c index b119e8feaa8..69947d21c14 100644 --- a/dlls/wined3d/shader_sm4.c +++ b/dlls/wined3d/shader_sm4.c @@ -509,8 +509,8 @@ static const enum wined3d_shader_resource_type resource_type_table[] = static const enum wined3d_data_type data_type_table[] = { /* 0 */ WINED3D_DATA_FLOAT, - /* WINED3D_SM4_DATA_UNORM */ WINED3D_DATA_UNORM, - /* WINED3D_SM4_DATA_SNORM */ WINED3D_DATA_SNORM, + /* WINED3D_SM4_DATA_UNORM */ WINED3D_DATA_FLOAT, + /* WINED3D_SM4_DATA_SNORM */ WINED3D_DATA_FLOAT, /* WINED3D_SM4_DATA_INT */ WINED3D_DATA_INT, /* WINED3D_SM4_DATA_UINT */ WINED3D_DATA_UINT, /* WINED3D_SM4_DATA_FLOAT */ WINED3D_DATA_FLOAT, @@ -565,8 +565,8 @@ static void shader_sm4_read_dcl_resource(struct wined3d_shader_instruction *ins, { enum wined3d_sm4_resource_type resource_type; enum wined3d_sm4_data_type data_type; - enum wined3d_data_type reg_data_type; DWORD components; + BOOL uav;
resource_type = (opcode_token & WINED3D_SM4_RESOURCE_TYPE_MASK) >> WINED3D_SM4_RESOURCE_TYPE_SHIFT; if (!resource_type || (resource_type >= ARRAY_SIZE(resource_type_table))) @@ -578,8 +578,8 @@ static void shader_sm4_read_dcl_resource(struct wined3d_shader_instruction *ins, { ins->declaration.semantic.resource_type = resource_type_table[resource_type]; } - reg_data_type = opcode == WINED3D_SM4_OP_DCL_RESOURCE ? WINED3D_DATA_RESOURCE : WINED3D_DATA_UAV; - shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], reg_data_type, &ins->declaration.semantic.reg); + uav = opcode != WINED3D_SM4_OP_DCL_RESOURCE; + shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, &ins->declaration.semantic.reg);
components = *tokens++; if ((components & 0xfff0) != (components & 0xf) * 0x1110) @@ -596,7 +596,7 @@ static void shader_sm4_read_dcl_resource(struct wined3d_shader_instruction *ins, ins->declaration.semantic.resource_data_type = data_type_table[data_type]; }
- if (reg_data_type == WINED3D_DATA_UAV) + if (uav) ins->flags = (opcode_token & WINED3D_SM5_UAV_FLAGS_MASK) >> WINED3D_SM5_UAV_FLAGS_SHIFT; }
@@ -616,14 +616,14 @@ static void shader_sm4_read_dcl_sampler(struct wined3d_shader_instruction *ins, ins->flags = (opcode_token & WINED3D_SM4_SAMPLER_MODE_MASK) >> WINED3D_SM4_SAMPLER_MODE_SHIFT; if (ins->flags & ~WINED3D_SM4_SAMPLER_COMPARISON) FIXME("Unhandled sampler mode %#x.\n", ins->flags); - shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_SAMPLER, &ins->declaration.dst); + shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, &ins->declaration.dst); }
static void shader_sm4_read_dcl_index_range(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv) { - shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_OPAQUE, + shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, &ins->declaration.index_range.first_register); ins->declaration.index_range.last_register = *tokens; } @@ -731,7 +731,7 @@ static void shader_sm5_read_fcall(struct wined3d_shader_instruction *ins, struct wined3d_sm4_data *priv) { priv->src_param[0].reg.u.fp_body_idx = *tokens++; - shader_sm4_read_src_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_OPAQUE, &priv->src_param[0]); + shader_sm4_read_src_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, &priv->src_param[0]); }
static void shader_sm5_read_dcl_function_body(struct wined3d_shader_instruction *ins, @@ -812,7 +812,7 @@ static void shader_sm5_read_dcl_uav_raw(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv) { - shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UAV, &ins->declaration.dst); + shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, &ins->declaration.dst); ins->flags = (opcode_token & WINED3D_SM5_UAV_FLAGS_MASK) >> WINED3D_SM5_UAV_FLAGS_SHIFT; }
@@ -820,7 +820,7 @@ static void shader_sm5_read_dcl_uav_structured(struct wined3d_shader_instruction DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv) { - shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UAV, + shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, &ins->declaration.structured_resource.reg); ins->flags = (opcode_token & WINED3D_SM5_UAV_FLAGS_MASK) >> WINED3D_SM5_UAV_FLAGS_SHIFT; ins->declaration.structured_resource.byte_stride = *tokens; @@ -854,7 +854,7 @@ static void shader_sm5_read_dcl_resource_structured(struct wined3d_shader_instru DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv) { - shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_RESOURCE, + shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, &ins->declaration.structured_resource.reg); ins->declaration.structured_resource.byte_stride = *tokens; if (ins->declaration.structured_resource.byte_stride % 4) @@ -865,7 +865,7 @@ static void shader_sm5_read_dcl_resource_raw(struct wined3d_shader_instruction * DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv) { - shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_RESOURCE, &ins->declaration.dst); + shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, &ins->declaration.dst); }
static void shader_sm5_read_sync(struct wined3d_shader_instruction *ins, @@ -875,15 +875,13 @@ static void shader_sm5_read_sync(struct wined3d_shader_instruction *ins, ins->flags = (opcode_token & WINED3D_SM5_SYNC_FLAGS_MASK) >> WINED3D_SM5_SYNC_FLAGS_SHIFT; }
-/* - * f -> WINED3D_DATA_FLOAT - * i -> WINED3D_DATA_INT - * u -> WINED3D_DATA_UINT - * O -> WINED3D_DATA_OPAQUE - * R -> WINED3D_DATA_RESOURCE - * S -> WINED3D_DATA_SAMPLER - * U -> WINED3D_DATA_UAV - */ +/* f -> FLOAT + * i -> INT + * u -> UINT + * O -> OPAQUE + * R -> RESOURCE + * S -> SAMPLER + * U -> UAV */ static const struct wined3d_sm4_opcode_info opcode_table[] = { {WINED3D_SM4_OP_ADD, WINED3DSIH_ADD, "f", "ff"}, @@ -1207,15 +1205,11 @@ static enum wined3d_data_type map_data_type(char t) case 'i': return WINED3D_DATA_INT; case 'u': - return WINED3D_DATA_UINT; case 'O': - return WINED3D_DATA_OPAQUE; case 'R': - return WINED3D_DATA_RESOURCE; case 'S': - return WINED3D_DATA_SAMPLER; case 'U': - return WINED3D_DATA_UAV; + return WINED3D_DATA_UINT; default: ERR("Invalid data type '%c'.\n", t); return WINED3D_DATA_FLOAT; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index d190f7ccfd6..3d637005353 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -503,13 +503,7 @@ enum wined3d_data_type { WINED3D_DATA_FLOAT, WINED3D_DATA_INT, - WINED3D_DATA_RESOURCE, - WINED3D_DATA_SAMPLER, - WINED3D_DATA_UAV, WINED3D_DATA_UINT, - WINED3D_DATA_UNORM, - WINED3D_DATA_SNORM, - WINED3D_DATA_OPAQUE, };
enum wined3d_immconst_type
On Tue, Jun 12, 2018 at 6:41 PM, Matteo Bruni mbruni@codeweavers.com wrote:
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 20d4f0773dd..a2c3f00559a 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -2134,14 +2134,6 @@ static void shader_dump_decl_usage(struct wined3d_string_buffer *buffer, shader_addline(buffer, " (uint)"); break;
case WINED3D_DATA_UNORM:
shader_addline(buffer, " (unorm)");
break;
case WINED3D_DATA_SNORM:
shader_addline(buffer, " (snorm)");
break;
I don't like that it won't print the correct data type for declarations. For example, after the patch "dcl_uav_typed_texture2d (snorm) u0" is "dcl_uav_typed_texture2d (float) u0".
2018-06-13 10:37 GMT+02:00 Józef Kucia joseph.kucia@gmail.com:
On Tue, Jun 12, 2018 at 6:41 PM, Matteo Bruni mbruni@codeweavers.com wrote:
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 20d4f0773dd..a2c3f00559a 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -2134,14 +2134,6 @@ static void shader_dump_decl_usage(struct wined3d_string_buffer *buffer, shader_addline(buffer, " (uint)"); break;
case WINED3D_DATA_UNORM:
shader_addline(buffer, " (unorm)");
break;
case WINED3D_DATA_SNORM:
shader_addline(buffer, " (snorm)");
break;
I don't like that it won't print the correct data type for declarations. For example, after the patch "dcl_uav_typed_texture2d (snorm) u0" is "dcl_uav_typed_texture2d (float) u0".
Yeah, it's a downside of the "simplification". Would printing something more generic like "(float / unorm / snorm)" work for you? Any other idea?
On Wed, Jun 13, 2018 at 8:29 PM, Matteo Bruni matteo.mystral@gmail.com wrote:
2018-06-13 10:37 GMT+02:00 Józef Kucia joseph.kucia@gmail.com:
On Tue, Jun 12, 2018 at 6:41 PM, Matteo Bruni mbruni@codeweavers.com wrote:
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 20d4f0773dd..a2c3f00559a 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -2134,14 +2134,6 @@ static void shader_dump_decl_usage(struct wined3d_string_buffer *buffer, shader_addline(buffer, " (uint)"); break;
case WINED3D_DATA_UNORM:
shader_addline(buffer, " (unorm)");
break;
case WINED3D_DATA_SNORM:
shader_addline(buffer, " (snorm)");
break;
I don't like that it won't print the correct data type for declarations. For example, after the patch "dcl_uav_typed_texture2d (snorm) u0" is "dcl_uav_typed_texture2d (float) u0".
Yeah, it's a downside of the "simplification". Would printing something more generic like "(float / unorm / snorm)" work for you? Any other idea?
Perhaps it's possible to keep wined3d_data_type for wined3d_shader_semantic, or preserve the type information in wined3d_shader_semantic differently.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- With the previous patch it became a subset of the public enum wined3d_component_type.
dlls/wined3d/glsl_shader.c | 96 +++++++++++++++++++++--------------------- dlls/wined3d/shader.c | 28 ++++++------ dlls/wined3d/shader_sm1.c | 14 +++--- dlls/wined3d/shader_sm4.c | 72 +++++++++++++++---------------- dlls/wined3d/wined3d_private.h | 13 ++---- 5 files changed, 108 insertions(+), 115 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index ffe0c2d7e14..cd4780a6419 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -88,7 +88,7 @@ struct glsl_sample_function struct wined3d_string_buffer *name; unsigned int coord_mask; unsigned int deriv_mask; - enum wined3d_data_type data_type; + enum wined3d_component_type data_type; BOOL output_single_component; unsigned int offset_size; }; @@ -2522,15 +2522,15 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
switch (reg_maps->resource_info[entry->resource_idx].data_type) { - case WINED3D_DATA_FLOAT: + case WINED3D_TYPE_FLOAT: sampler_type_prefix = ""; break;
- case WINED3D_DATA_INT: + case WINED3D_TYPE_INT: sampler_type_prefix = "i"; break;
- case WINED3D_DATA_UINT: + case WINED3D_TYPE_UINT: sampler_type_prefix = "u"; break;
@@ -2638,17 +2638,17 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
switch (reg_maps->uav_resource_info[i].data_type) { - case WINED3D_DATA_FLOAT: + case WINED3D_TYPE_FLOAT: image_type_prefix = ""; read_format = "r32f"; break;
- case WINED3D_DATA_INT: + case WINED3D_TYPE_INT: image_type_prefix = "i"; read_format = "r32i"; break;
- case WINED3D_DATA_UINT: + case WINED3D_TYPE_UINT: image_type_prefix = "u"; read_format = "r32ui"; break; @@ -2844,7 +2844,7 @@ static void shader_glsl_fixup_scalar_register_variable(char *register_name, /** Writes the GLSL variable name that corresponds to the register that the * DX opcode parameter is trying to access */ static void shader_glsl_get_register_name(const struct wined3d_shader_register *reg, - enum wined3d_data_type data_type, char *register_name, BOOL *is_color, + enum wined3d_component_type data_type, char *register_name, BOOL *is_color, const struct wined3d_shader_instruction *ins) { /* oPos, oFog and oPts in D3D */ @@ -3080,16 +3080,16 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register * case WINED3D_IMMCONST_SCALAR: switch (data_type) { - case WINED3D_DATA_FLOAT: + case WINED3D_TYPE_FLOAT: if (gl_info->supported[ARB_SHADER_BIT_ENCODING]) sprintf(register_name, "uintBitsToFloat(%#xu)", reg->u.immconst_data[0]); else wined3d_ftoa(*(const float *)reg->u.immconst_data, register_name); break; - case WINED3D_DATA_INT: + case WINED3D_TYPE_INT: sprintf(register_name, "%#x", reg->u.immconst_data[0]); break; - case WINED3D_DATA_UINT: + case WINED3D_TYPE_UINT: sprintf(register_name, "%#xu", reg->u.immconst_data[0]); break; default: @@ -3101,7 +3101,7 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register * case WINED3D_IMMCONST_VEC4: switch (data_type) { - case WINED3D_DATA_FLOAT: + case WINED3D_TYPE_FLOAT: if (gl_info->supported[ARB_SHADER_BIT_ENCODING]) { sprintf(register_name, "uintBitsToFloat(uvec4(%#xu, %#xu, %#xu, %#xu))", @@ -3118,12 +3118,12 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register * imm_str[0], imm_str[1], imm_str[2], imm_str[3]); } break; - case WINED3D_DATA_INT: + case WINED3D_TYPE_INT: sprintf(register_name, "ivec4(%#x, %#x, %#x, %#x)", reg->u.immconst_data[0], reg->u.immconst_data[1], reg->u.immconst_data[2], reg->u.immconst_data[3]); break; - case WINED3D_DATA_UINT: + case WINED3D_TYPE_UINT: sprintf(register_name, "uvec4(%#xu, %#xu, %#xu, %#xu)", reg->u.immconst_data[0], reg->u.immconst_data[1], reg->u.immconst_data[2], reg->u.immconst_data[3]); @@ -3319,22 +3319,22 @@ static void shader_glsl_get_swizzle(const struct wined3d_shader_src_param *param }
static void shader_glsl_sprintf_cast(struct wined3d_string_buffer *dst_param, const char *src_param, - enum wined3d_data_type dst_data_type, enum wined3d_data_type src_data_type) + enum wined3d_component_type dst_type, enum wined3d_component_type src_type) { - if (dst_data_type == src_data_type) + if (dst_type == src_type) { string_buffer_sprintf(dst_param, "%s", src_param); return; }
- if (src_data_type == WINED3D_DATA_FLOAT) + if (src_type == WINED3D_TYPE_FLOAT) { - switch (dst_data_type) + switch (dst_type) { - case WINED3D_DATA_INT: + case WINED3D_TYPE_INT: string_buffer_sprintf(dst_param, "floatBitsToInt(%s)", src_param); return; - case WINED3D_DATA_UINT: + case WINED3D_TYPE_UINT: string_buffer_sprintf(dst_param, "floatBitsToUint(%s)", src_param); return; default: @@ -3342,19 +3342,19 @@ static void shader_glsl_sprintf_cast(struct wined3d_string_buffer *dst_param, co } }
- if (src_data_type == WINED3D_DATA_UINT && dst_data_type == WINED3D_DATA_FLOAT) + if (src_type == WINED3D_TYPE_UINT && dst_type == WINED3D_TYPE_FLOAT) { string_buffer_sprintf(dst_param, "uintBitsToFloat(%s)", src_param); return; }
- if (src_data_type == WINED3D_DATA_INT && dst_data_type == WINED3D_DATA_FLOAT) + if (src_type == WINED3D_TYPE_INT && dst_type == WINED3D_TYPE_FLOAT) { string_buffer_sprintf(dst_param, "intBitsToFloat(%s)", src_param); return; }
- FIXME("Unhandled cast from %#x to %#x.\n", src_data_type, dst_data_type); + FIXME("Unhandled cast from %#x to %#x.\n", src_type, dst_type); string_buffer_sprintf(dst_param, "%s", src_param); }
@@ -3363,11 +3363,11 @@ static void shader_glsl_sprintf_cast(struct wined3d_string_buffer *dst_param, co * caller needs this information as well. */ static void shader_glsl_add_src_param_ext(const struct wined3d_shader_instruction *ins, const struct wined3d_shader_src_param *wined3d_src, DWORD mask, struct glsl_src_param *glsl_src, - enum wined3d_data_type data_type) + enum wined3d_component_type data_type) { struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data; struct wined3d_string_buffer *reg_name = string_buffer_get(priv->string_buffers); - enum wined3d_data_type param_data_type; + enum wined3d_component_type param_data_type; BOOL is_color = FALSE; char swizzle_str[6];
@@ -3392,10 +3392,10 @@ static void shader_glsl_add_src_param_ext(const struct wined3d_shader_instructio case WINED3DSPR_PRIMID: case WINED3DSPR_THREADGROUPID: case WINED3DSPR_THREADID: - param_data_type = WINED3D_DATA_INT; + param_data_type = WINED3D_TYPE_INT; break; default: - param_data_type = WINED3D_DATA_FLOAT; + param_data_type = WINED3D_TYPE_FLOAT; break; }
@@ -3430,7 +3430,7 @@ static DWORD shader_glsl_add_dst_param(const struct wined3d_shader_instruction * /* Append the destination part of the instruction to the buffer, return the effective write mask */ static DWORD shader_glsl_append_dst_ext(struct wined3d_string_buffer *buffer, const struct wined3d_shader_instruction *ins, const struct wined3d_shader_dst_param *dst, - enum wined3d_data_type data_type) + enum wined3d_component_type data_type) { struct glsl_dst_param glsl_dst; DWORD mask; @@ -3439,15 +3439,15 @@ static DWORD shader_glsl_append_dst_ext(struct wined3d_string_buffer *buffer, { switch (data_type) { - case WINED3D_DATA_FLOAT: + case WINED3D_TYPE_FLOAT: shader_addline(buffer, "%s%s = %s(", glsl_dst.reg_name, glsl_dst.mask_str, shift_glsl_tab[dst->shift]); break; - case WINED3D_DATA_INT: + case WINED3D_TYPE_INT: shader_addline(buffer, "%s%s = %sintBitsToFloat(", glsl_dst.reg_name, glsl_dst.mask_str, shift_glsl_tab[dst->shift]); break; - case WINED3D_DATA_UINT: + case WINED3D_TYPE_UINT: shader_addline(buffer, "%s%s = %suintBitsToFloat(", glsl_dst.reg_name, glsl_dst.mask_str, shift_glsl_tab[dst->shift]); break; @@ -4009,7 +4009,7 @@ static void shader_glsl_udiv(const struct wined3d_shader_instruction *ins) shader_glsl_add_src_param(ins, &ins->src[1], write_mask, &src1_param); shader_addline(buffer, "%s %% %s);\n", src0_param.param_str, src1_param.param_str);
- shader_glsl_append_dst_ext(buffer, ins, &ins->dst[0], WINED3D_DATA_FLOAT); + shader_glsl_append_dst_ext(buffer, ins, &ins->dst[0], WINED3D_TYPE_FLOAT); shader_addline(buffer, "tmp0%s);\n", dst_mask); } else @@ -4287,7 +4287,7 @@ static void shader_glsl_bitwise_op(const struct wined3d_shader_instruction *ins) dst.write_mask = ins->dst[0].write_mask & (WINED3DSP_WRITEMASK_0 << i); if (tmp_dst && (write_mask = shader_glsl_get_write_mask(&dst, mask_char))) shader_addline(buffer, "tmp0%s = %sBitsToFloat(", mask_char, - dst.reg.data_type == WINED3D_DATA_INT ? "int" : "uint"); + dst.reg.data_type == WINED3D_TYPE_INT ? "int" : "uint"); else if (!(write_mask = shader_glsl_append_dst_ext(buffer, ins, &dst, dst.reg.data_type))) continue;
@@ -4301,7 +4301,7 @@ static void shader_glsl_bitwise_op(const struct wined3d_shader_instruction *ins)
if (tmp_dst) { - shader_glsl_append_dst_ext(buffer, ins, &ins->dst[0], WINED3D_DATA_FLOAT); + shader_glsl_append_dst_ext(buffer, ins, &ins->dst[0], WINED3D_TYPE_FLOAT); shader_glsl_get_write_mask(&ins->dst[0], mask_char); shader_addline(buffer, "tmp0%s);\n", mask_char); } @@ -5441,7 +5441,7 @@ static void shader_glsl_atomic(const struct wined3d_shader_instruction *ins) struct wined3d_string_buffer *buffer = ins->ctx->buffer; enum wined3d_shader_resource_type resource_type; struct wined3d_string_buffer *address; - enum wined3d_data_type data_type; + enum wined3d_component_type data_type; unsigned int resource_idx, stride; const char *op, *resource; DWORD coord_mask; @@ -5457,7 +5457,7 @@ static void shader_glsl_atomic(const struct wined3d_shader_instruction *ins) return; } resource = "g"; - data_type = WINED3D_DATA_UINT; + data_type = WINED3D_TYPE_UINT; coord_mask = 1; stride = reg_maps->tgsm[resource_idx].stride; } @@ -5509,7 +5509,7 @@ static void shader_glsl_atomic(const struct wined3d_shader_instruction *ins) op = "atomicMax"; else op = "imageAtomicMax"; - if (data_type != WINED3D_DATA_INT) + if (data_type != WINED3D_TYPE_INT) { FIXME("Unhandled opcode %#x for unsigned integers.\n", ins->handler_idx); return; @@ -5521,7 +5521,7 @@ static void shader_glsl_atomic(const struct wined3d_shader_instruction *ins) op = "atomicMin"; else op = "imageAtomicMin"; - if (data_type != WINED3D_DATA_INT) + if (data_type != WINED3D_TYPE_INT) { FIXME("Unhandled opcode %#x for unsigned integers.\n", ins->handler_idx); return; @@ -5540,7 +5540,7 @@ static void shader_glsl_atomic(const struct wined3d_shader_instruction *ins) op = "atomicMax"; else op = "imageAtomicMax"; - if (data_type != WINED3D_DATA_UINT) + if (data_type != WINED3D_TYPE_UINT) { FIXME("Unhandled opcode %#x for signed integers.\n", ins->handler_idx); return; @@ -5552,7 +5552,7 @@ static void shader_glsl_atomic(const struct wined3d_shader_instruction *ins) op = "atomicMin"; else op = "imageAtomicMin"; - if (data_type != WINED3D_DATA_UINT) + if (data_type != WINED3D_TYPE_UINT) { FIXME("Unhandled opcode %#x for signed integers.\n", ins->handler_idx); return; @@ -5636,7 +5636,7 @@ static void shader_glsl_ld_uav(const struct wined3d_shader_instruction *ins) const struct wined3d_shader_version *version = ®_maps->shader_version; enum wined3d_shader_resource_type resource_type; struct glsl_src_param image_coord_param; - enum wined3d_data_type data_type; + enum wined3d_component_type data_type; DWORD coord_mask, write_mask; unsigned int uav_idx; char dst_swizzle[6]; @@ -5757,7 +5757,7 @@ static void shader_glsl_store_uav(const struct wined3d_shader_instruction *ins) const struct wined3d_shader_version *version = ®_maps->shader_version; struct glsl_src_param image_coord_param, image_data_param; enum wined3d_shader_resource_type resource_type; - enum wined3d_data_type data_type; + enum wined3d_component_type data_type; unsigned int uav_idx; DWORD coord_mask;
@@ -5947,7 +5947,7 @@ static void shader_glsl_resinfo(const struct wined3d_shader_instruction *ins) enum wined3d_shader_resource_type resource_type; enum wined3d_shader_register_type reg_type; unsigned int resource_idx, bind_idx, i; - enum wined3d_data_type dst_data_type; + enum wined3d_component_type dst_data_type; struct glsl_src_param lod_param; BOOL supports_mipmaps; char dst_swizzle[6]; @@ -5955,7 +5955,7 @@ static void shader_glsl_resinfo(const struct wined3d_shader_instruction *ins)
dst_data_type = ins->dst[0].reg.data_type; if (ins->flags == WINED3DSI_RESINFO_UINT) - dst_data_type = WINED3D_DATA_UINT; + dst_data_type = WINED3D_TYPE_UINT; else if (ins->flags) FIXME("Unhandled flags %#x.\n", ins->flags);
@@ -5983,7 +5983,7 @@ static void shader_glsl_resinfo(const struct wined3d_shader_instruction *ins) write_mask = shader_glsl_append_dst_ext(buffer, ins, &ins->dst[0], dst_data_type); shader_glsl_get_swizzle(&ins->src[1], FALSE, write_mask, dst_swizzle);
- if (dst_data_type == WINED3D_DATA_UINT) + if (dst_data_type == WINED3D_TYPE_UINT) shader_addline(buffer, "uvec4("); else shader_addline(buffer, "vec4("); @@ -6036,21 +6036,21 @@ static void shader_glsl_sample_info(const struct wined3d_shader_instruction *ins const struct wined3d_shader_dst_param *dst = ins->dst; const struct wined3d_shader_src_param *src = ins->src; enum wined3d_shader_resource_type resource_type; - enum wined3d_data_type dst_data_type; + enum wined3d_component_type dst_data_type; unsigned int resource_idx, bind_idx; char dst_swizzle[6]; DWORD write_mask;
dst_data_type = dst->reg.data_type; if (ins->flags == WINED3DSI_SAMPLE_INFO_UINT) - dst_data_type = WINED3D_DATA_UINT; + dst_data_type = WINED3D_TYPE_UINT; else if (ins->flags) FIXME("Unhandled flags %#x.\n", ins->flags);
write_mask = shader_glsl_append_dst_ext(buffer, ins, dst, dst_data_type); shader_glsl_get_swizzle(src, FALSE, write_mask, dst_swizzle);
- if (dst_data_type == WINED3D_DATA_UINT) + if (dst_data_type == WINED3D_TYPE_UINT) shader_addline(buffer, "uvec4("); else shader_addline(buffer, "vec4("); diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index a2c3f00559a..192e95f4473 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -1270,7 +1270,7 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, DWORD co break; } reg_maps->resource_info[reg_idx].type = WINED3D_SHADER_RESOURCE_BUFFER; - reg_maps->resource_info[reg_idx].data_type = WINED3D_DATA_UINT; + reg_maps->resource_info[reg_idx].data_type = WINED3D_TYPE_UINT; reg_maps->resource_info[reg_idx].flags = WINED3D_VIEW_BUFFER_RAW; } else if (ins.handler_idx == WINED3DSIH_DCL_RESOURCE_STRUCTURED) @@ -1282,7 +1282,7 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, DWORD co break; } reg_maps->resource_info[reg_idx].type = WINED3D_SHADER_RESOURCE_BUFFER; - reg_maps->resource_info[reg_idx].data_type = WINED3D_DATA_UINT; + reg_maps->resource_info[reg_idx].data_type = WINED3D_TYPE_UINT; reg_maps->resource_info[reg_idx].flags = 0; reg_maps->resource_info[reg_idx].stride = ins.declaration.structured_resource.byte_stride / 4; } @@ -1356,7 +1356,7 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, DWORD co if (ins.flags) FIXME("Ignoring raw UAV flags %#x.\n", ins.flags); reg_maps->uav_resource_info[reg_idx].type = WINED3D_SHADER_RESOURCE_BUFFER; - reg_maps->uav_resource_info[reg_idx].data_type = WINED3D_DATA_UINT; + reg_maps->uav_resource_info[reg_idx].data_type = WINED3D_TYPE_UINT; reg_maps->uav_resource_info[reg_idx].flags = WINED3D_VIEW_BUFFER_RAW; } else if (ins.handler_idx == WINED3DSIH_DCL_UAV_STRUCTURED) @@ -1370,7 +1370,7 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, DWORD co if (ins.flags) FIXME("Ignoring structured UAV flags %#x.\n", ins.flags); reg_maps->uav_resource_info[reg_idx].type = WINED3D_SHADER_RESOURCE_BUFFER; - reg_maps->uav_resource_info[reg_idx].data_type = WINED3D_DATA_UINT; + reg_maps->uav_resource_info[reg_idx].data_type = WINED3D_TYPE_UINT; reg_maps->uav_resource_info[reg_idx].flags = 0; reg_maps->uav_resource_info[reg_idx].stride = ins.declaration.structured_resource.byte_stride / 4; } @@ -1609,7 +1609,7 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, DWORD co
TRACE("Setting fake 2D resource for 1.x pixelshader.\n"); reg_maps->resource_info[reg_idx].type = WINED3D_SHADER_RESOURCE_TEXTURE_2D; - reg_maps->resource_info[reg_idx].data_type = WINED3D_DATA_FLOAT; + reg_maps->resource_info[reg_idx].data_type = WINED3D_TYPE_FLOAT; shader_record_sample(reg_maps, reg_idx, reg_idx, reg_idx);
/* texbem is only valid with < 1.4 pixel shaders */ @@ -2122,15 +2122,15 @@ static void shader_dump_decl_usage(struct wined3d_string_buffer *buffer, shader_dump_uav_flags(buffer, flags); switch (semantic->resource_data_type) { - case WINED3D_DATA_FLOAT: + case WINED3D_TYPE_FLOAT: shader_addline(buffer, " (float)"); break;
- case WINED3D_DATA_INT: + case WINED3D_TYPE_INT: shader_addline(buffer, " (int)"); break;
- case WINED3D_DATA_UINT: + case WINED3D_TYPE_UINT: shader_addline(buffer, " (uint)"); break;
@@ -2434,13 +2434,13 @@ static void shader_dump_register(struct wined3d_string_buffer *buffer, case WINED3D_IMMCONST_SCALAR: switch (reg->data_type) { - case WINED3D_DATA_FLOAT: + case WINED3D_TYPE_FLOAT: shader_addline(buffer, "%.8e", *(const float *)reg->u.immconst_data); break; - case WINED3D_DATA_INT: + case WINED3D_TYPE_INT: shader_addline(buffer, "%d", reg->u.immconst_data[0]); break; - case WINED3D_DATA_UINT: + case WINED3D_TYPE_UINT: shader_addline(buffer, "%u", reg->u.immconst_data[0]); break; default: @@ -2452,17 +2452,17 @@ static void shader_dump_register(struct wined3d_string_buffer *buffer, case WINED3D_IMMCONST_VEC4: switch (reg->data_type) { - case WINED3D_DATA_FLOAT: + case WINED3D_TYPE_FLOAT: shader_addline(buffer, "%.8e, %.8e, %.8e, %.8e", *(const float *)®->u.immconst_data[0], *(const float *)®->u.immconst_data[1], *(const float *)®->u.immconst_data[2], *(const float *)®->u.immconst_data[3]); break; - case WINED3D_DATA_INT: + case WINED3D_TYPE_INT: shader_addline(buffer, "%d, %d, %d, %d", reg->u.immconst_data[0], reg->u.immconst_data[1], reg->u.immconst_data[2], reg->u.immconst_data[3]); break; - case WINED3D_DATA_UINT: + case WINED3D_TYPE_UINT: shader_addline(buffer, "%u, %u, %u, %u", reg->u.immconst_data[0], reg->u.immconst_data[1], reg->u.immconst_data[2], reg->u.immconst_data[3]); diff --git a/dlls/wined3d/shader_sm1.c b/dlls/wined3d/shader_sm1.c index 0c6bb933174..b57b67b8dcc 100644 --- a/dlls/wined3d/shader_sm1.c +++ b/dlls/wined3d/shader_sm1.c @@ -468,7 +468,7 @@ static void shader_parse_src_param(DWORD param, const struct wined3d_shader_src_ { src->reg.type = ((param & WINED3D_SM1_REGISTER_TYPE_MASK) >> WINED3D_SM1_REGISTER_TYPE_SHIFT) | ((param & WINED3D_SM1_REGISTER_TYPE_MASK2) >> WINED3D_SM1_REGISTER_TYPE_SHIFT2); - src->reg.data_type = WINED3D_DATA_FLOAT; + src->reg.data_type = WINED3D_TYPE_FLOAT; src->reg.idx[0].offset = param & WINED3D_SM1_REGISTER_NUMBER_MASK; src->reg.idx[0].rel_addr = rel_addr; src->reg.idx[1].offset = ~0U; @@ -482,7 +482,7 @@ static void shader_parse_dst_param(DWORD param, const struct wined3d_shader_src_ { dst->reg.type = ((param & WINED3D_SM1_REGISTER_TYPE_MASK) >> WINED3D_SM1_REGISTER_TYPE_SHIFT) | ((param & WINED3D_SM1_REGISTER_TYPE_MASK2) >> WINED3D_SM1_REGISTER_TYPE_SHIFT2); - dst->reg.data_type = WINED3D_DATA_FLOAT; + dst->reg.data_type = WINED3D_TYPE_FLOAT; dst->reg.idx[0].offset = param & WINED3D_SM1_REGISTER_NUMBER_MASK; dst->reg.idx[0].rel_addr = rel_addr; dst->reg.idx[1].offset = ~0U; @@ -645,12 +645,12 @@ static void shader_sm1_read_semantic(const DWORD **ptr, struct wined3d_shader_se { semantic->resource_type = resource_type_table[resource_type]; } - semantic->resource_data_type = WINED3D_DATA_FLOAT; + semantic->resource_data_type = WINED3D_TYPE_FLOAT; shader_parse_dst_param(dst_token, NULL, &semantic->reg); }
static void shader_sm1_read_immconst(const DWORD **ptr, struct wined3d_shader_src_param *src_param, - enum wined3d_immconst_type type, enum wined3d_data_type data_type) + enum wined3d_immconst_type type, enum wined3d_component_type data_type) { unsigned int count = type == WINED3D_IMMCONST_VEC4 ? 4 : 1; src_param->reg.type = WINED3DSPR_IMMCONST; @@ -761,17 +761,17 @@ static void shader_sm1_read_instruction(void *data, const DWORD **ptr, struct wi else if (ins->handler_idx == WINED3DSIH_DEF) { shader_sm1_read_dst_param(priv, &p, &priv->dst_param, &priv->dst_rel_addr); - shader_sm1_read_immconst(&p, &priv->src_param[0], WINED3D_IMMCONST_VEC4, WINED3D_DATA_FLOAT); + shader_sm1_read_immconst(&p, &priv->src_param[0], WINED3D_IMMCONST_VEC4, WINED3D_TYPE_FLOAT); } else if (ins->handler_idx == WINED3DSIH_DEFB) { shader_sm1_read_dst_param(priv, &p, &priv->dst_param, &priv->dst_rel_addr); - shader_sm1_read_immconst(&p, &priv->src_param[0], WINED3D_IMMCONST_SCALAR, WINED3D_DATA_UINT); + shader_sm1_read_immconst(&p, &priv->src_param[0], WINED3D_IMMCONST_SCALAR, WINED3D_TYPE_UINT); } else if (ins->handler_idx == WINED3DSIH_DEFI) { shader_sm1_read_dst_param(priv, &p, &priv->dst_param, &priv->dst_rel_addr); - shader_sm1_read_immconst(&p, &priv->src_param[0], WINED3D_IMMCONST_VEC4, WINED3D_DATA_INT); + shader_sm1_read_immconst(&p, &priv->src_param[0], WINED3D_IMMCONST_VEC4, WINED3D_TYPE_INT); } else { diff --git a/dlls/wined3d/shader_sm4.c b/dlls/wined3d/shader_sm4.c index 69947d21c14..338bae3a8dd 100644 --- a/dlls/wined3d/shader_sm4.c +++ b/dlls/wined3d/shader_sm4.c @@ -506,26 +506,26 @@ static const enum wined3d_shader_resource_type resource_type_table[] = /* WINED3D_SM4_RESOURCE_TEXTURE_CUBEARRAY */ WINED3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY, };
-static const enum wined3d_data_type data_type_table[] = -{ - /* 0 */ WINED3D_DATA_FLOAT, - /* WINED3D_SM4_DATA_UNORM */ WINED3D_DATA_FLOAT, - /* WINED3D_SM4_DATA_SNORM */ WINED3D_DATA_FLOAT, - /* WINED3D_SM4_DATA_INT */ WINED3D_DATA_INT, - /* WINED3D_SM4_DATA_UINT */ WINED3D_DATA_UINT, - /* WINED3D_SM4_DATA_FLOAT */ WINED3D_DATA_FLOAT, +static const enum wined3d_component_type data_type_table[] = +{ + /* 0 */ WINED3D_TYPE_FLOAT, + /* WINED3D_SM4_DATA_UNORM */ WINED3D_TYPE_FLOAT, + /* WINED3D_SM4_DATA_SNORM */ WINED3D_TYPE_FLOAT, + /* WINED3D_SM4_DATA_INT */ WINED3D_TYPE_INT, + /* WINED3D_SM4_DATA_UINT */ WINED3D_TYPE_UINT, + /* WINED3D_SM4_DATA_FLOAT */ WINED3D_TYPE_FLOAT, };
static BOOL shader_sm4_read_src_param(struct wined3d_sm4_data *priv, const DWORD **ptr, const DWORD *end, - enum wined3d_data_type data_type, struct wined3d_shader_src_param *src_param); + enum wined3d_component_type data_type, struct wined3d_shader_src_param *src_param); static BOOL shader_sm4_read_dst_param(struct wined3d_sm4_data *priv, const DWORD **ptr, const DWORD *end, - enum wined3d_data_type data_type, struct wined3d_shader_dst_param *dst_param); + enum wined3d_component_type data_type, struct wined3d_shader_dst_param *dst_param);
static void shader_sm4_read_conditional_op(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv) { - shader_sm4_read_src_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, &priv->src_param[0]); + shader_sm4_read_src_param(priv, &tokens, &tokens[token_count], WINED3D_TYPE_UINT, &priv->src_param[0]); ins->flags = (opcode_token & WINED3D_SM4_CONDITIONAL_NZ) ? WINED3D_SHADER_CONDITIONAL_OP_NZ : WINED3D_SHADER_CONDITIONAL_OP_Z; } @@ -579,7 +579,7 @@ static void shader_sm4_read_dcl_resource(struct wined3d_shader_instruction *ins, ins->declaration.semantic.resource_type = resource_type_table[resource_type]; } uav = opcode != WINED3D_SM4_OP_DCL_RESOURCE; - shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, &ins->declaration.semantic.reg); + shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_TYPE_UINT, &ins->declaration.semantic.reg);
components = *tokens++; if ((components & 0xfff0) != (components & 0xf) * 0x1110) @@ -589,7 +589,7 @@ static void shader_sm4_read_dcl_resource(struct wined3d_shader_instruction *ins, if (!data_type || (data_type >= ARRAY_SIZE(data_type_table))) { FIXME("Unhandled data type %#x.\n", data_type); - ins->declaration.semantic.resource_data_type = WINED3D_DATA_FLOAT; + ins->declaration.semantic.resource_data_type = WINED3D_TYPE_FLOAT; } else { @@ -604,7 +604,7 @@ static void shader_sm4_read_dcl_constant_buffer(struct wined3d_shader_instructio DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv) { - shader_sm4_read_src_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_FLOAT, &ins->declaration.src); + shader_sm4_read_src_param(priv, &tokens, &tokens[token_count], WINED3D_TYPE_FLOAT, &ins->declaration.src); if (opcode_token & WINED3D_SM4_INDEX_TYPE_MASK) ins->flags |= WINED3DSI_INDEXED_DYNAMIC; } @@ -616,14 +616,14 @@ static void shader_sm4_read_dcl_sampler(struct wined3d_shader_instruction *ins, ins->flags = (opcode_token & WINED3D_SM4_SAMPLER_MODE_MASK) >> WINED3D_SM4_SAMPLER_MODE_SHIFT; if (ins->flags & ~WINED3D_SM4_SAMPLER_COMPARISON) FIXME("Unhandled sampler mode %#x.\n", ins->flags); - shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, &ins->declaration.dst); + shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_TYPE_UINT, &ins->declaration.dst); }
static void shader_sm4_read_dcl_index_range(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv) { - shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, + shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_TYPE_UINT, &ins->declaration.index_range.first_register); ins->declaration.index_range.last_register = *tokens; } @@ -680,14 +680,14 @@ static void shader_sm4_read_declaration_dst(struct wined3d_shader_instruction *i DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv) { - shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_FLOAT, &ins->declaration.dst); + shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_TYPE_FLOAT, &ins->declaration.dst); }
static void shader_sm4_read_declaration_register_semantic(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv) { - shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_FLOAT, + shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_TYPE_FLOAT, &ins->declaration.register_semantic.reg); ins->declaration.register_semantic.sysval_semantic = *tokens; } @@ -697,7 +697,7 @@ static void shader_sm4_read_dcl_input_ps(struct wined3d_shader_instruction *ins, struct wined3d_sm4_data *priv) { ins->flags = (opcode_token & WINED3D_SM4_INTERPOLATION_MODE_MASK) >> WINED3D_SM4_INTERPOLATION_MODE_SHIFT; - shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_FLOAT, &ins->declaration.dst); + shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_TYPE_FLOAT, &ins->declaration.dst); }
static void shader_sm4_read_dcl_input_ps_siv(struct wined3d_shader_instruction *ins, @@ -705,7 +705,7 @@ static void shader_sm4_read_dcl_input_ps_siv(struct wined3d_shader_instruction * struct wined3d_sm4_data *priv) { ins->flags = (opcode_token & WINED3D_SM4_INTERPOLATION_MODE_MASK) >> WINED3D_SM4_INTERPOLATION_MODE_SHIFT; - shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_FLOAT, + shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_TYPE_FLOAT, &ins->declaration.register_semantic.reg); ins->declaration.register_semantic.sysval_semantic = *tokens; } @@ -731,7 +731,7 @@ static void shader_sm5_read_fcall(struct wined3d_shader_instruction *ins, struct wined3d_sm4_data *priv) { priv->src_param[0].reg.u.fp_body_idx = *tokens++; - shader_sm4_read_src_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, &priv->src_param[0]); + shader_sm4_read_src_param(priv, &tokens, &tokens[token_count], WINED3D_TYPE_UINT, &priv->src_param[0]); }
static void shader_sm5_read_dcl_function_body(struct wined3d_shader_instruction *ins, @@ -812,7 +812,7 @@ static void shader_sm5_read_dcl_uav_raw(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv) { - shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, &ins->declaration.dst); + shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_TYPE_UINT, &ins->declaration.dst); ins->flags = (opcode_token & WINED3D_SM5_UAV_FLAGS_MASK) >> WINED3D_SM5_UAV_FLAGS_SHIFT; }
@@ -820,7 +820,7 @@ static void shader_sm5_read_dcl_uav_structured(struct wined3d_shader_instruction DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv) { - shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, + shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_TYPE_UINT, &ins->declaration.structured_resource.reg); ins->flags = (opcode_token & WINED3D_SM5_UAV_FLAGS_MASK) >> WINED3D_SM5_UAV_FLAGS_SHIFT; ins->declaration.structured_resource.byte_stride = *tokens; @@ -832,7 +832,7 @@ static void shader_sm5_read_dcl_tgsm_raw(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv) { - shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_FLOAT, &ins->declaration.tgsm_raw.reg); + shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_TYPE_FLOAT, &ins->declaration.tgsm_raw.reg); ins->declaration.tgsm_raw.byte_count = *tokens; if (ins->declaration.tgsm_raw.byte_count % 4) FIXME("Byte count %u is not multiple of 4.\n", ins->declaration.tgsm_raw.byte_count); @@ -842,7 +842,7 @@ static void shader_sm5_read_dcl_tgsm_structured(struct wined3d_shader_instructio DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv) { - shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_FLOAT, + shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_TYPE_FLOAT, &ins->declaration.tgsm_structured.reg); ins->declaration.tgsm_structured.byte_stride = *tokens++; ins->declaration.tgsm_structured.structure_count = *tokens; @@ -854,7 +854,7 @@ static void shader_sm5_read_dcl_resource_structured(struct wined3d_shader_instru DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv) { - shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, + shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_TYPE_UINT, &ins->declaration.structured_resource.reg); ins->declaration.structured_resource.byte_stride = *tokens; if (ins->declaration.structured_resource.byte_stride % 4) @@ -865,7 +865,7 @@ static void shader_sm5_read_dcl_resource_raw(struct wined3d_shader_instruction * DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv) { - shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, &ins->declaration.dst); + shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_TYPE_UINT, &ins->declaration.dst); }
static void shader_sm5_read_sync(struct wined3d_shader_instruction *ins, @@ -1196,23 +1196,23 @@ static void map_register(const struct wined3d_sm4_data *priv, struct wined3d_sha } }
-static enum wined3d_data_type map_data_type(char t) +static enum wined3d_component_type map_data_type(char t) { switch (t) { case 'f': - return WINED3D_DATA_FLOAT; + return WINED3D_TYPE_FLOAT; case 'i': - return WINED3D_DATA_INT; + return WINED3D_TYPE_INT; case 'u': case 'O': case 'R': case 'S': case 'U': - return WINED3D_DATA_UINT; + return WINED3D_TYPE_UINT; default: ERR("Invalid data type '%c'.\n", t); - return WINED3D_DATA_FLOAT; + return WINED3D_TYPE_FLOAT; } }
@@ -1376,7 +1376,7 @@ static BOOL shader_sm4_read_reg_idx(struct wined3d_sm4_data *priv, const DWORD * reg_idx->offset = *(*ptr)++; else reg_idx->offset = 0; - shader_sm4_read_src_param(priv, ptr, end, WINED3D_DATA_INT, rel_addr); + shader_sm4_read_src_param(priv, ptr, end, WINED3D_TYPE_INT, rel_addr); } else { @@ -1388,7 +1388,7 @@ static BOOL shader_sm4_read_reg_idx(struct wined3d_sm4_data *priv, const DWORD * }
static BOOL shader_sm4_read_param(struct wined3d_sm4_data *priv, const DWORD **ptr, const DWORD *end, - enum wined3d_data_type data_type, struct wined3d_shader_register *param, + enum wined3d_component_type data_type, struct wined3d_shader_register *param, enum wined3d_shader_src_modifier *modifier) { enum wined3d_sm4_register_type register_type; @@ -1520,7 +1520,7 @@ static BOOL shader_sm4_read_param(struct wined3d_sm4_data *priv, const DWORD **p }
static BOOL shader_sm4_read_src_param(struct wined3d_sm4_data *priv, const DWORD **ptr, const DWORD *end, - enum wined3d_data_type data_type, struct wined3d_shader_src_param *src_param) + enum wined3d_component_type data_type, struct wined3d_shader_src_param *src_param) { DWORD token;
@@ -1571,7 +1571,7 @@ static BOOL shader_sm4_read_src_param(struct wined3d_sm4_data *priv, const DWORD }
static BOOL shader_sm4_read_dst_param(struct wined3d_sm4_data *priv, const DWORD **ptr, const DWORD *end, - enum wined3d_data_type data_type, struct wined3d_shader_dst_param *dst_param) + enum wined3d_component_type data_type, struct wined3d_shader_dst_param *dst_param) { enum wined3d_shader_src_modifier modifier; DWORD token; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 3d637005353..9c72ffdbe85 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -499,13 +499,6 @@ enum wined3d_shader_register_type WINED3DSPR_RASTERIZER, };
-enum wined3d_data_type -{ - WINED3D_DATA_FLOAT, - WINED3D_DATA_INT, - WINED3D_DATA_UINT, -}; - enum wined3d_immconst_type { WINED3D_IMMCONST_SCALAR, @@ -930,7 +923,7 @@ struct wined3d_shader_version struct wined3d_shader_resource_info { enum wined3d_shader_resource_type type; - enum wined3d_data_type data_type; + enum wined3d_component_type data_type; unsigned int flags; unsigned int stride; }; @@ -1068,7 +1061,7 @@ struct wined3d_shader_register_index struct wined3d_shader_register { enum wined3d_shader_register_type type; - enum wined3d_data_type data_type; + enum wined3d_component_type data_type; struct wined3d_shader_register_index idx[2]; enum wined3d_immconst_type immconst_type; union @@ -1104,7 +1097,7 @@ struct wined3d_shader_semantic enum wined3d_decl_usage usage; UINT usage_idx; enum wined3d_shader_resource_type resource_type; - enum wined3d_data_type resource_data_type; + enum wined3d_component_type resource_data_type; struct wined3d_shader_dst_param reg; };
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v2: Reuse shader_glsl_sprintf_cast() in shader_glsl_generate_color_output(), avoid semantic string comparison.
Let me know if you prefer the old version after all (and the old patch doesn't apply anymore).
dlls/wined3d/glsl_shader.c | 128 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 111 insertions(+), 17 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index cd4780a6419..d5dc8be136a 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -3318,12 +3318,12 @@ static void shader_glsl_get_swizzle(const struct wined3d_shader_src_param *param shader_glsl_swizzle_to_str(param->swizzle, fixup, mask, swizzle_str); }
-static void shader_glsl_sprintf_cast(struct wined3d_string_buffer *dst_param, const char *src_param, +static void shader_glsl_sprintf_cast(struct wined3d_string_buffer *buffer, const char *arg, enum wined3d_component_type dst_type, enum wined3d_component_type src_type) { if (dst_type == src_type) { - string_buffer_sprintf(dst_param, "%s", src_param); + string_buffer_sprintf(buffer, "%s", arg); return; }
@@ -3332,10 +3332,10 @@ static void shader_glsl_sprintf_cast(struct wined3d_string_buffer *dst_param, co switch (dst_type) { case WINED3D_TYPE_INT: - string_buffer_sprintf(dst_param, "floatBitsToInt(%s)", src_param); + string_buffer_sprintf(buffer, "floatBitsToInt(%s)", arg); return; case WINED3D_TYPE_UINT: - string_buffer_sprintf(dst_param, "floatBitsToUint(%s)", src_param); + string_buffer_sprintf(buffer, "floatBitsToUint(%s)", arg); return; default: break; @@ -3344,18 +3344,18 @@ static void shader_glsl_sprintf_cast(struct wined3d_string_buffer *dst_param, co
if (src_type == WINED3D_TYPE_UINT && dst_type == WINED3D_TYPE_FLOAT) { - string_buffer_sprintf(dst_param, "uintBitsToFloat(%s)", src_param); + string_buffer_sprintf(buffer, "uintBitsToFloat(%s)", arg); return; }
if (src_type == WINED3D_TYPE_INT && dst_type == WINED3D_TYPE_FLOAT) { - string_buffer_sprintf(dst_param, "intBitsToFloat(%s)", src_param); + string_buffer_sprintf(buffer, "intBitsToFloat(%s)", arg); return; }
FIXME("Unhandled cast from %#x to %#x.\n", src_type, dst_type); - string_buffer_sprintf(dst_param, "%s", src_param); + string_buffer_sprintf(buffer, "%s", arg); }
/* From a given parameter token, generate the corresponding GLSL string. @@ -7616,9 +7616,48 @@ static void shader_glsl_enable_extensions(struct wined3d_string_buffer *buffer, shader_addline(buffer, "#extension GL_EXT_texture_array : enable\n"); }
+static void shader_glsl_generate_color_output(struct wined3d_string_buffer *buffer, + const struct wined3d_gl_info *gl_info, const struct wined3d_shader *shader, + struct wined3d_string_buffer_list *string_buffers) +{ + const struct wined3d_shader_signature *output_signature = &shader->output_signature; + struct wined3d_string_buffer *src, *assignment; + unsigned int i; + + if (output_signature->element_count) + { + src = string_buffer_get(string_buffers); + assignment = string_buffer_get(string_buffers); + for (i = 0; i < output_signature->element_count; ++i) + { + const struct wined3d_shader_signature_element *output = &output_signature->elements[i]; + + /* register_idx is set to ~0u for non-color outputs. */ + if (output->register_idx == ~0u) + continue; + shader_addline(buffer, "color_out%u = ", output->semantic_idx); + string_buffer_sprintf(src, "ps_out[%u]", output->semantic_idx); + shader_glsl_sprintf_cast(assignment, src->buffer, output->component_type, WINED3D_TYPE_FLOAT); + shader_addline(buffer, "%s;\n", assignment->buffer); + } + string_buffer_release(string_buffers, src); + string_buffer_release(string_buffers, assignment); + } + else + { + DWORD mask = shader->reg_maps.rt_mask; + + while (mask) + { + i = wined3d_bit_scan(&mask); + shader_addline(buffer, "color_out%u = ps_out[%u];\n", i, i); + } + } +} + static void shader_glsl_generate_ps_epilogue(const struct wined3d_gl_info *gl_info, struct wined3d_string_buffer *buffer, const struct wined3d_shader *shader, - const struct ps_compile_args *args) + const struct ps_compile_args *args, struct wined3d_string_buffer_list *string_buffers) { const struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
@@ -7637,6 +7676,26 @@ static void shader_glsl_generate_ps_epilogue(const struct wined3d_gl_info *gl_in
if (reg_maps->sample_mask) shader_addline(buffer, "gl_SampleMask[0] = floatBitsToInt(sample_mask);\n"); + + if (!needs_legacy_glsl_syntax(gl_info)) + shader_glsl_generate_color_output(buffer, gl_info, shader, string_buffers); +} + +static const char *shader_glsl_get_ps_output_format(enum wined3d_component_type component_type) +{ + static const char formats[][6] = + { + "", /* WINED3D_TYPE_UNKNOWN */ + "uvec4", /* WINED3D_TYPE_UINT */ + "ivec4", /* WINED3D_TYPE_INT */ + "vec4", /* WINED3D_TYPE_FLOAT */ + }; + if (component_type < WINED3D_TYPE_UNKNOWN || component_type > WINED3D_TYPE_FLOAT) + { + WARN("Unexpected component_type %#x.\n", component_type); + return formats[WINED3D_TYPE_FLOAT]; + } + return formats[component_type]; }
/* Context activation is done by the caller. */ @@ -7819,9 +7878,35 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context
if (!needs_legacy_glsl_syntax(gl_info)) { - if (shader_glsl_use_explicit_attrib_location(gl_info)) - shader_addline(buffer, "layout(location = 0) "); - shader_addline(buffer, "out vec4 ps_out[%u];\n", gl_info->limits.buffers); + const struct wined3d_shader_signature *output_signature = &shader->output_signature; + + shader_addline(buffer, "vec4 ps_out[%u];\n", gl_info->limits.buffers); + if (output_signature->element_count) + { + for (i = 0; i < output_signature->element_count; ++i) + { + const struct wined3d_shader_signature_element *output = &output_signature->elements[i]; + + if (output->register_idx == ~0u) + continue; + if (shader_glsl_use_explicit_attrib_location(gl_info)) + shader_addline(buffer, "layout(location = %u) ", output->semantic_idx); + shader_addline(buffer, "out %s color_out%u;\n", + shader_glsl_get_ps_output_format(output->component_type), output->semantic_idx); + } + } + else + { + DWORD mask = reg_maps->rt_mask; + + while (mask) + { + i = wined3d_bit_scan(&mask); + if (shader_glsl_use_explicit_attrib_location(gl_info)) + shader_addline(buffer, "layout(location = %u) ", i); + shader_addline(buffer, "out vec4 color_out%u;\n", i); + } + } }
if (shader->limits->constant_float + extra_constants_needed >= gl_info->limits.glsl_ps_float_constants) @@ -7906,7 +7991,7 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context
/* In SM4+ the shader epilogue is generated by the "ret" instruction. */ if (reg_maps->shader_version.major < 4) - shader_glsl_generate_ps_epilogue(gl_info, buffer, shader, args); + shader_glsl_generate_ps_epilogue(gl_info, buffer, shader, args, string_buffers);
shader_addline(buffer, "}\n");
@@ -8403,7 +8488,7 @@ static void shader_glsl_generate_shader_epilogue(const struct wined3d_shader_con switch (shader->reg_maps.shader_version.type) { case WINED3D_SHADER_TYPE_PIXEL: - shader_glsl_generate_ps_epilogue(gl_info, buffer, shader, priv->cur_ps_args); + shader_glsl_generate_ps_epilogue(gl_info, buffer, shader, priv->cur_ps_args, priv->string_buffers); break; case WINED3D_SHADER_TYPE_VERTEX: shader_glsl_generate_vs_epilogue(gl_info, buffer, shader, priv->cur_vs_args); @@ -9539,9 +9624,10 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv *
if (!needs_legacy_glsl_syntax(gl_info)) { + shader_addline(buffer, "vec4 ps_out[1];\n"); if (shader_glsl_use_explicit_attrib_location(gl_info)) shader_addline(buffer, "layout(location = 0) "); - shader_addline(buffer, "out vec4 ps_out[1];\n"); + shader_addline(buffer, "out vec4 color_out0;\n"); }
shader_addline(buffer, "vec4 tmp0, tmp1;\n"); @@ -9881,6 +9967,8 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv * shader_glsl_generate_fog_code(buffer, gl_info, settings->fog);
shader_glsl_generate_alpha_test(buffer, gl_info, alpha_test_func); + if (!needs_legacy_glsl_syntax(gl_info)) + shader_addline(buffer, "color_out0 = ps_out[0];\n");
shader_addline(buffer, "}\n");
@@ -10422,13 +10510,17 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const } } checkGLcall("glBindAttribLocation"); - string_buffer_release(&priv->string_buffers, tmp_name);
if (!needs_legacy_glsl_syntax(gl_info)) { - GL_EXTCALL(glBindFragDataLocation(program_id, 0, "ps_out")); - checkGLcall("glBindFragDataLocation"); + for (i = 0; i < MAX_RENDER_TARGET_VIEWS; ++i) + { + string_buffer_sprintf(tmp_name, "color_out%u", i); + GL_EXTCALL(glBindFragDataLocation(program_id, i, tmp_name->buffer)); + checkGLcall("glBindFragDataLocation"); + } } + string_buffer_release(&priv->string_buffers, tmp_name); }
if (hshader) @@ -12796,6 +12888,8 @@ static GLuint glsl_blitter_generate_program(struct wined3d_glsl_blitter *blitter shader_glsl_add_version_declaration(buffer, gl_info); shader_addline(buffer, "uniform sampler%s sampler;\n", tex_type); declare_in_varying(gl_info, buffer, FALSE, "vec3 out_texcoord;\n"); + /* TODO: Declare the out variable with the correct type (and put it in the + * blitter args). */ if (!needs_legacy_glsl_syntax(gl_info)) shader_addline(buffer, "out vec4 ps_out[1];\n");
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v2: Get rid of more todo_wine.
dlls/d3d10core/tests/device.c | 4 ++-- dlls/d3d11/tests/d3d11.c | 3 --- dlls/d3d8/device.c | 8 ++++++++ dlls/d3d9/device.c | 8 ++++++++ dlls/d3d9/tests/device.c | 2 +- dlls/d3d9/tests/visual.c | 2 +- dlls/d3dx10_43/tests/d3dx10.c | 4 ++-- dlls/wined3d/device.c | 6 ++---- 8 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c index 2687ec52b76..8fba7a3badd 100644 --- a/dlls/d3d10core/tests/device.c +++ b/dlls/d3d10core/tests/device.c @@ -5493,8 +5493,8 @@ float4 main(float4 color : COLOR) : SV_TARGET for (i = 0; i < D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; ++i) { ok(!tmp_buffer[i], "Got unexpected vertex buffer %p in slot %u.\n", tmp_buffer[i], i); - todo_wine ok(!stride[i], "Got unexpected stride %u in slot %u.\n", stride[i], i); - todo_wine ok(!offset[i], "Got unexpected offset %u in slot %u.\n", offset[i], i); + ok(!stride[i], "Got unexpected stride %u in slot %u.\n", stride[i], i); + ok(!offset[i], "Got unexpected offset %u in slot %u.\n", offset[i], i); } ID3D10Device_IAGetIndexBuffer(device, tmp_buffer, &format, offset); ok(!tmp_buffer[0], "Got unexpected index buffer %p.\n", tmp_buffer[0]); diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index c641372bc8e..ee8d465cb4e 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -10647,11 +10647,8 @@ static void test_clear_state(void) for (i = 0; i < D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; ++i) { ok(!tmp_buffer[i], "Got unexpected vertex buffer %p in slot %u.\n", tmp_buffer[i], i); - todo_wine_if(i < D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT) - { ok(!stride[i], "Got unexpected stride %u in slot %u.\n", stride[i], i); ok(!offset[i], "Got unexpected offset %u in slot %u.\n", offset[i], i); - } } ID3D11DeviceContext_IAGetIndexBuffer(context, tmp_buffer, &format, offset); ok(!tmp_buffer[0], "Got unexpected index buffer %p.\n", tmp_buffer[0]); diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 616886bcafa..e4869c2618e 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -3102,6 +3102,14 @@ static HRESULT WINAPI d3d8_device_SetStreamSource(IDirect3DDevice8 *iface, iface, stream_idx, buffer, stride);
wined3d_mutex_lock(); + if (!stride) + { + struct wined3d_buffer *wined3d_buffer; + unsigned int cur_offset; + + hr = wined3d_device_get_stream_source(device->wined3d_device, stream_idx, &wined3d_buffer, + &cur_offset, &stride); + } hr = wined3d_device_set_stream_source(device->wined3d_device, stream_idx, buffer_impl ? buffer_impl->wined3d_buffer : NULL, 0, stride); wined3d_mutex_unlock(); diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 5d0f5071836..e32bc14af5b 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -3348,6 +3348,14 @@ static HRESULT WINAPI d3d9_device_SetStreamSource(IDirect3DDevice9Ex *iface, iface, stream_idx, buffer, offset, stride);
wined3d_mutex_lock(); + if (!stride) + { + struct wined3d_buffer *wined3d_buffer; + unsigned int cur_offset; + + hr = wined3d_device_get_stream_source(device->wined3d_device, stream_idx, &wined3d_buffer, + &cur_offset, &stride); + } hr = wined3d_device_set_stream_source(device->wined3d_device, stream_idx, buffer_impl ? buffer_impl->wined3d_buffer : NULL, offset, stride); wined3d_mutex_unlock(); diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index b71058de486..66bf5b00c50 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -2973,7 +2973,7 @@ static void test_draw_primitive(void) ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#x.\n", hr); ok(!current_vb, "Unexpected vb %p.\n", current_vb); ok(!offset, "Unexpected offset %u.\n", offset); - todo_wine ok(!stride, "Unexpected stride %u.\n", stride); + ok(!stride, "Unexpected stride %u.\n", stride);
/* NULL index buffer, valid vertex declaration, NULL stream source. */ hr = IDirect3DDevice9_SetIndices(device, NULL); diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 1e213abeb18..95982e05155 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -23132,7 +23132,7 @@ static void test_drawindexedprimitiveup(void) ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#x.\n", hr); ok(!vb, "Unexpected vb %p.\n", vb); ok(!offset, "Unexpected offset %u.\n", offset); - todo_wine ok(!stride, "Unexpected stride %u.\n", stride); + ok(!stride, "Unexpected stride %u.\n", stride);
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0); ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index 2bf92cdb589..cd61d766e8e 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -480,8 +480,8 @@ float4 main(float4 color : COLOR) : SV_TARGET for (i = 0; i < D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; ++i) { ok(!tmp_buffer[i], "Got unexpected vertex buffer %p in slot %u.\n", tmp_buffer[i], i); - todo_wine ok(!stride[i], "Got unexpected stride %u in slot %u.\n", stride[i], i); - todo_wine ok(!offset[i], "Got unexpected offset %u in slot %u.\n", offset[i], i); + ok(!stride[i], "Got unexpected stride %u in slot %u.\n", stride[i], i); + ok(!offset[i], "Got unexpected offset %u in slot %u.\n", offset[i], i); } ID3D10Device_IAGetIndexBuffer(device, tmp_buffer, &format, offset); ok(!tmp_buffer[0], "Got unexpected index buffer %p.\n", tmp_buffer[0]); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 8ef74b6ef0f..6776c5c5e0c 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1389,12 +1389,10 @@ HRESULT CDECL wined3d_device_set_stream_source(struct wined3d_device *device, UI }
stream->buffer = buffer; + stream->stride = stride; + stream->offset = offset; if (buffer) - { - stream->stride = stride; - stream->offset = offset; wined3d_buffer_incref(buffer); - }
if (!device->recording) wined3d_cs_emit_set_stream_source(device->cs, stream_idx, buffer, offset, stride);
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at https://testbot.winehq.org/JobDetails.pl?Key=39087
Your paranoid android.
=== w1064 (64 bit visual) === visual.c:8592: Test failed: Got unexpected color 0x00007580 for quad 2 (different colors).
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com