47#define WINED3D_GLSL_SAMPLE_PROJECTED 0x01
48#define WINED3D_GLSL_SAMPLE_LOD 0x02
49#define WINED3D_GLSL_SAMPLE_GRAD 0x04
50#define WINED3D_GLSL_SAMPLE_LOAD 0x08
51#define WINED3D_GLSL_SAMPLE_OFFSET 0x10
351#define WINED3D_TO_STR(u) case u: return #u
387 FIXME(
"Unhandled shader type %#x.\n",
type);
428 ERR(
"Invalid vector size %u.\n",
size);
449 if (!*
p)
return NULL;
492 WARN(
"Info log received from GLSL shader #%u:\n",
id);
497 FIXME(
"Info log received from GLSL shader #%u:\n",
id);
527 GLint i, shader_count, source_size = -1;
534 ERR(
"Failed to allocate shader array memory.\n");
539 for (
i = 0;
i < shader_count; ++
i)
546 if (source_size < tmp)
550 if (!(
source = heap_alloc_zero(tmp)))
552 ERR(
"Failed to allocate %d bytes for shader source.\n", tmp);
563 FIXME(
" GL_COMPILE_STATUS: %d.\n", tmp);
627 block_idx =
GL_EXTCALL(glGetUniformBlockIndex(program_id,
name->buffer));
640 unsigned int i, mapped_unit;
646 name_loc =
GL_EXTCALL(glGetUniformLocation(program_id, sampler_name->
buffer));
650 mapped_unit = tex_unit_map ? tex_unit_map[
base +
i] :
base +
i;
653 ERR(
"Trying to load sampler %s on unsupported unit %u.\n", sampler_name->
buffer, mapped_unit);
657 TRACE(
"Loading sampler %s on unit %u.\n", sampler_name->
buffer, mapped_unit);
658 GL_EXTCALL(glUniform1i(name_loc, mapped_unit));
667 const DWORD *tex_unit_map;
671 if (sampler_idx >=
count)
674 return base + sampler_idx;
675 return tex_unit_map[
base + sampler_idx];
680 unsigned int sampler_idx)
686 ERR(
"Unmapped sampler %u.\n", sampler_idx);
695 const DWORD *tex_unit_map;
720 icb_location =
GL_EXTCALL(glGetUniformLocation(program_id, icb_name->
buffer));
751 TRACE(
"Loading image %s on unit %u.\n",
name->buffer,
i);
786 *strings_length +=
buffer->content_size + 1;
791 unsigned int *varying_count,
char **
strings,
unsigned int *strings_length,
810 char *
strings,
unsigned int *strings_length,
GLenum buffer_mode)
815 highest_output_slot = 0;
824 highest_output_slot =
max(highest_output_slot,
e->output_slot);
825 if (
e->output_slot != buffer_idx)
830 FIXME(
"Unhandled stream %u.\n",
e->stream_idx);
843 if (
e->component_idx ||
e->component_count != 4)
847 FIXME(
"Unsupported component range %u-%u.\n",
e->component_idx,
e->component_count);
854 e->register_idx,
e->component_idx,
e->component_idx +
e->component_count - 1);
864 if (buffer_idx < so_desc->buffer_stride_count
865 && stride < so_desc->buffer_strides[buffer_idx] / 4)
872 if (highest_output_slot <= buffer_idx)
883 *varying_count =
count;
914 FIXME(
"ARB_transform_feedback3 is needed for stream output gaps.\n");
917 ++element_count[so_desc->
elements[
i].output_slot];
929 if (element_count[
i] != 1)
934 if (element_count[
i])
936 FIXME(
"Only single element per buffer is allowed in separate mode.\n");
949 ERR(
"Out of memory.\n");
955 ERR(
"Out of memory.\n");
976 unsigned int heap_idx = 1;
979 if (
heap->entries[heap_idx].version <=
version)
return;
981 idx =
heap->entries[heap_idx].idx;
982 if (constant_locations[
idx] != -1)
986 while (stack_idx >= 0)
989 switch(
stack[stack_idx])
993 unsigned int left_idx = heap_idx << 1;
994 if (left_idx < heap->
size &&
heap->entries[left_idx].version >
version)
997 idx =
heap->entries[heap_idx].idx;
998 if (constant_locations[
idx] != -1)
1014 unsigned int right_idx = (heap_idx << 1) + 1;
1015 if (right_idx < heap->
size &&
heap->entries[right_idx].version >
version)
1017 heap_idx = right_idx;
1018 idx =
heap->entries[heap_idx].idx;
1019 if (constant_locations[
idx] != -1)
1052 clamped_constant[0] =
data->x < -1.0f ? -1.0f :
data->x > 1.0f ? 1.0f :
data->x;
1053 clamped_constant[1] =
data->y < -1.0f ? -1.0f :
data->y > 1.0f ? 1.0f :
data->y;
1054 clamped_constant[2] =
data->z < -1.0f ? -1.0f :
data->z > 1.0f ? 1.0f :
data->z;
1055 clamped_constant[3] =
data->w < -1.0f ? -1.0f :
data->w > 1.0f ? 1.0f :
data->w;
1066 unsigned int heap_idx = 1;
1069 if (
heap->entries[heap_idx].version <=
version)
return;
1071 idx =
heap->entries[heap_idx].idx;
1075 while (stack_idx >= 0)
1078 switch(
stack[stack_idx])
1082 unsigned int left_idx = heap_idx << 1;
1083 if (left_idx < heap->
size &&
heap->entries[left_idx].version >
version)
1085 heap_idx = left_idx;
1086 idx =
heap->entries[heap_idx].idx;
1097 unsigned int right_idx = (heap_idx << 1) + 1;
1098 if (right_idx < heap->
size &&
heap->entries[right_idx].version >
version)
1100 heap_idx = right_idx;
1101 idx =
heap->entries[heap_idx].idx;
1127 if (
shader->reg_maps.shader_version.major == 1
1133 if (!
shader->load_local_constsF)
1135 TRACE(
"No need to load local float constants for this shader.\n");
1154 for (
i = 0; constants_set; constants_set >>= 1, ++
i)
1156 if (!(constants_set & 1))
continue;
1167 unsigned int idx = lconst->
idx;
1184 for (
i = 0; constants_set; constants_set >>= 1, ++
i)
1186 if (!(constants_set & 1))
continue;
1196 unsigned int idx = lconst->
idx;
1222 for (
i = 0; fixup; fixup >>= 1, ++
i)
1229 ERR(
"Nonexistent texture is flagged for NP2 texcoord fixup.\n");
1248 if (
prog->vs.texture_matrix_location[tex] == -1)
1263 GL_EXTCALL(glUniform4fv(
prog->vs.material_specular_location, 1, &
state->material.specular.r));
1268 static const float black[] = {0.0f, 0.0f, 0.0f, 0.0f};
1270 GL_EXTCALL(glUniform4fv(
prog->vs.material_specular_location, 1, black));
1272 GL_EXTCALL(glUniform4fv(
prog->vs.material_ambient_location, 1, &
state->material.ambient.r));
1273 GL_EXTCALL(glUniform4fv(
prog->vs.material_diffuse_location, 1, &
state->material.diffuse.r));
1274 GL_EXTCALL(glUniform4fv(
prog->vs.material_emissive_location, 1, &
state->material.emissive.r));
1294 temp.x = (src1->
x * src2->
_11) + (src1->
y * src2->
_21) + (src1->
z * src2->
_31) + (src1->
w * src2->
_41);
1295 temp.y = (src1->
x * src2->
_12) + (src1->
y * src2->
_22) + (src1->
z * src2->
_32) + (src1->
w * src2->
_42);
1296 temp.z = (src1->
x * src2->
_13) + (src1->
y * src2->
_23) + (src1->
z * src2->
_33) + (src1->
w * src2->
_43);
1297 temp.w = (src1->
x * src2->
_14) + (src1->
y * src2->
_24) + (src1->
z * src2->
_34) + (src1->
w * src2->
_44);
1375 GL_EXTCALL(glUniform1f(
prog->vs.pointsize_c_att_location, att[0]));
1377 GL_EXTCALL(glUniform1f(
prog->vs.pointsize_l_att_location, att[1]));
1379 GL_EXTCALL(glUniform1f(
prog->vs.pointsize_q_att_location, att[2]));
1398 GL_EXTCALL(glUniform1f(
prog->ps.fog_density_location, tmpvalue.f));
1449 for (
i = 0;
i < 3; ++
i)
1450 for (
j = 0;
j < 3; ++
j)
1463 float position_fixup[4];
1476 update_mask =
context->constant_update_mask &
prog->constant_update_mask;
1484 prog->vs.uniform_i_locations, vshader->
reg_maps.integer_constants);
1488 vshader->
reg_maps.boolean_constants);
1492 for (
i = 0;
i < gl_info->
limits.user_clip_distances; ++
i)
1503 GL_EXTCALL(glUniform4fv(
prog->gs.pos_fixup_location, 1, position_fixup));
1505 GL_EXTCALL(glUniform4fv(
prog->ds.pos_fixup_location, 1, position_fixup));
1507 GL_EXTCALL(glUniform4fv(
prog->vs.pos_fixup_location, 1, position_fixup));
1530 if (
prog->vs.modelview_matrix_location[
i] == -1)
1565 unsigned int point_idx, spot_idx, directional_idx, parallel_point_idx;
1566 DWORD point_count = 0;
1567 DWORD spot_count = 0;
1568 DWORD directional_count = 0;
1569 DWORD parallel_point_count = 0;
1576 switch (
state->lights[
i]->OriginalParms.type)
1585 ++directional_count;
1588 ++parallel_point_count;
1591 FIXME(
"Unhandled light type %#x.\n",
state->lights[
i]->OriginalParms.type);
1596 spot_idx = point_idx + point_count;
1597 directional_idx = spot_idx + spot_count;
1598 parallel_point_idx = directional_idx + directional_count;
1618 idx = directional_idx++;
1621 idx = parallel_point_idx++;
1637 prog->ps.uniform_i_locations, pshader->
reg_maps.integer_constants);
1641 pshader->
reg_maps.boolean_constants);
1647 if (
prog->ps.bumpenv_mat_location[
i] == -1)
1653 if (
prog->ps.bumpenv_lum_scale_location[
i] != -1)
1671 context->render_offscreen ? 1.0f : -1.0f,
1676 GL_EXTCALL(glUniform4fv(
prog->ps.ycorrection_location, 1, &correction_params.
x));
1688 if (
prog->ps.tex_factor_location != -1)
1695 GL_EXTCALL(glUniform4f(
prog->ps.specular_enable_location, 1.0f, 1.0f, 1.0f, 0.0f));
1697 GL_EXTCALL(glUniform4f(
prog->ps.specular_enable_location, 0.0f, 0.0f, 0.0f, 0.0f));
1701 if (
prog->ps.tss_constant_location[
i] == -1)
1724 TRACE(
"Max constant version reached, resetting to 0.\n");
1737 unsigned int *positions =
heap->positions;
1738 unsigned int heap_idx, parent_idx;
1742 heap_idx =
heap->size++;
1747 heap_idx = positions[
idx];
1750 while (heap_idx > 1)
1752 parent_idx = heap_idx >> 1;
1754 if (new_version <= entries[parent_idx].
version)
break;
1756 entries[heap_idx] = entries[parent_idx];
1757 positions[entries[parent_idx].
idx] = heap_idx;
1758 heap_idx = parent_idx;
1761 entries[heap_idx].
version = new_version;
1762 entries[heap_idx].
idx =
idx;
1763 positions[
idx] = heap_idx;
1792 unsigned int ret = gl_info->
limits.glsl_varyings / 4;
1794 if(shader_major > 3)
return ret;
1879 return "noperspective";
1881 FIXME(
"Unhandled interpolation mode %#x.\n",
mode);
1889 const DWORD *packed_interpolation_mode,
unsigned int register_idx)
1897 const DWORD *interpolation_mode,
BOOL unroll)
1907 for (
i = 0;
i < element_count; ++
i)
1921 declare_in_varying(gl_info,
buffer,
FALSE,
"vec4 ps_link[%u];\n", element_count);
1927 const DWORD *interpolation_mode)
1934 if (rasterizer_setup)
1937 for (
i = 0;
i < element_count; ++
i)
1939 const char *interpolation_qualifiers =
"";
1956 declare_out_varying(gl_info,
buffer,
FALSE,
"vec4 ps_link[%u];\n", element_count);
1962 switch (primitive_type)
1971 return "line_strip";
1977 return "triangle_strip";
1980 return "lines_adjacency";
1983 return "triangles_adjacency";
1999 return input_reg_used & (1u <<
idx);
2010 return input_reg_used & (1u <<
input->register_idx);
2016 const struct ps_compile_args *ps_args,
unsigned int resource_idx,
unsigned int sampler_idx)
2021 return shader->reg_maps.sampler_comparison_mode & (1u << sampler_idx);
2027 const struct wined3d_gl_info *gl_info,
const char *vector_type,
const char *scalar_type,
2039 unsigned int index =
e->register_idx;
2054 FIXME(
"Unhandled sysval semantic %#x.\n",
e->sysval_semantic);
2059 switch (
e->component_type)
2069 FIXME(
"Unhandled type %#x.\n",
e->component_type);
2088 unsigned int uniform_block_base, uniform_block_count;
2103 if (
shader->limits->constant_float > 0)
2105 unsigned max_constantsF;
2127 max_constantsF = gl_info->
limits.glsl_ps_float_constants;
2143 max_constantsF = gl_info->
limits.glsl_vs_float_constants - 3;
2145 max_constantsF -= gl_info->
limits.user_clip_distances;
2155 if (max_constantsF < shader->limits->constant_float)
2157 static unsigned int once;
2160 ERR_(winediag)(
"The hardware does not support enough uniform components to run this shader,"
2161 " it may not render correctly.\n");
2163 WARN(
"The hardware does not support enough uniform components to run this shader.\n");
2168 max_constantsF = gl_info->
limits.glsl_vs_float_constants;
2171 max_constantsF =
min(
shader->limits->constant_float, max_constantsF);
2190 &uniform_block_base, &uniform_block_count);
2207 const char *sampler_type_prefix, *sampler_type;
2208 BOOL shadow_sampler, tex_rect;
2214 ERR(
"Invalid resource index %u.\n",
entry->resource_idx);
2223 sampler_type_prefix =
"";
2227 sampler_type_prefix =
"i";
2231 sampler_type_prefix =
"u";
2235 sampler_type_prefix =
"";
2236 ERR(
"Unhandled resource data type %#x.\n", reg_maps->
resource_info[
i].data_type);
2244 sampler_type =
"samplerBuffer";
2249 sampler_type =
"sampler1DShadow";
2251 sampler_type =
"sampler1D";
2261 sampler_type =
"sampler2DRectShadow";
2263 sampler_type =
"sampler2DShadow";
2268 sampler_type =
"sampler2DRect";
2270 sampler_type =
"sampler2D";
2276 FIXME(
"Unsupported 3D shadow sampler.\n");
2277 sampler_type =
"sampler3D";
2282 sampler_type =
"samplerCubeShadow";
2284 sampler_type =
"samplerCube";
2289 sampler_type =
"sampler1DArrayShadow";
2291 sampler_type =
"sampler1DArray";
2296 sampler_type =
"sampler2DArrayShadow";
2298 sampler_type =
"sampler2DArray";
2303 sampler_type =
"samplerCubeArrayShadow";
2305 sampler_type =
"samplerCubeArray";
2309 sampler_type =
"sampler2DMS";
2313 sampler_type =
"sampler2DMSArray";
2317 sampler_type =
"unsupported_sampler";
2325 sampler_type_prefix, sampler_type, prefix,
entry->bind_idx);
2331 const char *image_type_prefix, *image_type, *read_format;
2341 image_type_prefix =
"";
2342 read_format =
"r32f";
2346 image_type_prefix =
"i";
2347 read_format =
"r32i";
2351 image_type_prefix =
"u";
2352 read_format =
"r32ui";
2356 image_type_prefix =
"";
2365 image_type =
"imageBuffer";
2369 image_type =
"image2D";
2373 image_type =
"image3D";
2377 image_type =
"image2DArray";
2381 image_type =
"unsupported_image";
2390 read_format, image_type_prefix, image_type, prefix,
i);
2393 image_type_prefix, image_type, prefix,
i);
2407 if (
shader->limits->packed_output)
2447 if (!
shader->load_local_constsF)
2484 const char *in_reg,
const char *in_regswizzle,
char *out_str)
2486 switch (src_modifier)
2491 sprintf(out_str,
"%s%s", in_reg, in_regswizzle);
2494 sprintf(out_str,
"-%s%s", in_reg, in_regswizzle);
2497 sprintf(out_str,
"!%s%s", in_reg, in_regswizzle);
2500 sprintf(out_str,
"(%s%s - vec4(0.5)%s)", in_reg, in_regswizzle, in_regswizzle);
2503 sprintf(out_str,
"-(%s%s - vec4(0.5)%s)", in_reg, in_regswizzle, in_regswizzle);
2506 sprintf(out_str,
"(2.0 * (%s%s - 0.5))", in_reg, in_regswizzle);
2509 sprintf(out_str,
"-(2.0 * (%s%s - 0.5))", in_reg, in_regswizzle);
2512 sprintf(out_str,
"(1.0 - %s%s)", in_reg, in_regswizzle);
2515 sprintf(out_str,
"(2.0 * %s%s)", in_reg, in_regswizzle);
2518 sprintf(out_str,
"-(2.0 * %s%s)", in_reg, in_regswizzle);
2521 sprintf(out_str,
"abs(%s%s)", in_reg, in_regswizzle);
2524 sprintf(out_str,
"-abs(%s%s)", in_reg, in_regswizzle);
2527 FIXME(
"Unhandled modifier %u\n", src_modifier);
2528 sprintf(out_str,
"%s%s", in_reg, in_regswizzle);
2538 sprintf(register_name,
"%s", glsl_variable);
2540 sprintf(register_name,
"ivec2(%s, 0)", glsl_variable);
2550 static const char *
const hwrastout_reg_names[] = {
"vs_out[10]",
"vs_out[11].x",
"vs_out[11].y"};
2558 char imm_str[4][17];
2560 if (
reg->idx[0].offset != ~0
U &&
reg->idx[0].rel_addr)
2562 if (
reg->idx[1].offset != ~0
U &&
reg->idx[1].rel_addr)
2569 sprintf(register_name,
"R%u",
reg->idx[0].offset);
2578 if (
reg->idx[0].rel_addr)
2579 FIXME(
"VS3 input registers relative addressing.\n");
2582 if (
reg->idx[0].rel_addr)
2584 sprintf(register_name,
"%s_in[%s + %u]",
2589 sprintf(register_name,
"%s_in%u", prefix,
reg->idx[0].offset);
2598 if (
reg->idx[0].rel_addr)
2600 if (
reg->idx[1].rel_addr)
2601 sprintf(register_name,
"shader_in[%s + %u].reg[%s + %u]",
2605 sprintf(register_name,
"shader_in[%s + %u].reg[%u]",
2607 reg->idx[1].offset);
2609 else if (
reg->idx[1].rel_addr)
2610 sprintf(register_name,
"shader_in[%u].reg[%s + %u]",
reg->idx[0].offset,
2613 sprintf(register_name,
"shader_in[%u].reg[%u]",
2614 reg->idx[0].offset,
reg->idx[1].offset);
2624 if (
reg->idx[0].rel_addr)
2631 &&
shader->u.ps.declared_in_count > in_count)
2634 "((%s + %u) > %u ? (%s + %u) > %u ? gl_SecondaryColor : gl_Color : %s_in[%s + %u])",
2646 &&
shader->u.ps.declared_in_count > in_count)
2648 sprintf(register_name,
"((%s) > %u ? (%s) > %u ? gl_SecondaryColor : gl_Color : %s_in[%s])",
2660 if (
idx == in_count)
sprintf(register_name,
"gl_Color");
2661 else if (
idx == in_count + 1)
sprintf(register_name,
"gl_SecondaryColor");
2662 else sprintf(register_name,
"%s_in[%u]", prefix,
idx);
2667 if (!
reg->idx[0].offset)
2668 strcpy(register_name,
"ffp_varying_diffuse");
2670 strcpy(register_name,
"ffp_varying_specular");
2678 if (
reg->idx[0].rel_addr)
2681 sprintf(register_name,
"(%s + %u >= 0 && %s + %u < %u ? %s_c[%s + %u] : vec4(0.0))",
2685 else if (
reg->idx[0].offset)
2686 sprintf(register_name,
"%s_c[%s + %u]", prefix, rel_param0.
param_str,
reg->idx[0].offset);
2693 sprintf(register_name,
"%s_lc%u", prefix,
reg->idx[0].offset);
2695 sprintf(register_name,
"%s_c[%u]", prefix,
reg->idx[0].offset);
2701 sprintf(register_name,
"%s_i[%u]", prefix,
reg->idx[0].offset);
2705 sprintf(register_name,
"%s_b[%u]", prefix,
reg->idx[0].offset);
2710 sprintf(register_name,
"T%u",
reg->idx[0].offset);
2712 sprintf(register_name,
"A%u",
reg->idx[0].offset);
2716 sprintf(register_name,
"aL%u", ins->
ctx->state->current_loop_reg - 1);
2720 sprintf(register_name,
"%s_sampler%u", prefix,
reg->idx[0].offset);
2725 if (
reg->idx[0].offset >= gl_info->
limits.buffers)
2726 WARN(
"Write to render target %u, only %d supported.\n",
2727 reg->idx[0].offset, gl_info->
limits.buffers);
2730 reg->idx[0].offset);
2734 sprintf(register_name,
"%s", hwrastout_reg_names[
reg->idx[0].offset]);
2740 sprintf(register_name,
"gl_FragDepth");
2744 if (!
reg->idx[0].offset)
2745 sprintf(register_name,
"%s_out[8]", prefix);
2747 sprintf(register_name,
"%s_out[9]", prefix);
2752 if (
reg->idx[0].rel_addr)
2753 sprintf(register_name,
"%s_out[%s + %u]",
2756 sprintf(register_name,
"%s_out[%u]", prefix,
reg->idx[0].offset);
2760 if (!
reg->idx[0].offset)
2763 sprintf(register_name,
"vpos");
2765 else if (
reg->idx[0].offset == 1)
2769 sprintf(register_name,
"(gl_FrontFacing ? 1.0 : -1.0)");
2773 FIXME(
"Unhandled misctype register %u.\n",
reg->idx[0].offset);
2774 sprintf(register_name,
"unrecognized_register");
2779 switch (
reg->immconst_type)
2786 sprintf(register_name,
"uintBitsToFloat(%#xu)",
reg->u.immconst_data[0]);
2791 sprintf(register_name,
"%#x",
reg->u.immconst_data[0]);
2796 sprintf(register_name,
"%#xu",
reg->u.immconst_data[0]);
2799 sprintf(register_name,
"<unhandled data type %#x>", data_type);
2810 sprintf(register_name,
"uintBitsToFloat(uvec4(%#xu, %#xu, %#xu, %#xu))",
2811 reg->u.immconst_data[0],
reg->u.immconst_data[1],
2812 reg->u.immconst_data[2],
reg->u.immconst_data[3]);
2820 sprintf(register_name,
"vec4(%s, %s, %s, %s)",
2821 imm_str[0], imm_str[1], imm_str[2], imm_str[3]);
2825 sprintf(register_name,
"ivec4(%#x, %#x, %#x, %#x)",
2826 reg->u.immconst_data[0],
reg->u.immconst_data[1],
2827 reg->u.immconst_data[2],
reg->u.immconst_data[3]);
2832 sprintf(register_name,
"uvec4(%#xu, %#xu, %#xu, %#xu)",
2833 reg->u.immconst_data[0],
reg->u.immconst_data[1],
2834 reg->u.immconst_data[2],
reg->u.immconst_data[3]);
2837 sprintf(register_name,
"<unhandled data type %#x>", data_type);
2843 FIXME(
"Unhandled immconst type %#x\n",
reg->immconst_type);
2844 sprintf(register_name,
"<unhandled_immconst_type %#x>",
reg->immconst_type);
2849 if (
reg->idx[1].rel_addr)
2850 sprintf(register_name,
"%s_cb%u[%s + %u]",
2851 prefix,
reg->idx[0].offset, rel_param1.
param_str,
reg->idx[1].offset);
2853 sprintf(register_name,
"%s_cb%u[%u]", prefix,
reg->idx[0].offset,
reg->idx[1].offset);
2857 if (
reg->idx[0].rel_addr)
2858 sprintf(register_name,
"%s_icb[%s + %u]", prefix, rel_param0.
param_str,
reg->idx[0].offset);
2860 sprintf(register_name,
"%s_icb[%u]", prefix,
reg->idx[0].offset);
2865 sprintf(register_name,
"gl_PrimitiveIDIn");
2867 sprintf(register_name,
"gl_PrimitiveID");
2871 if (
reg->idx[1].rel_addr)
2874 sprintf(register_name,
"X%u[%u]",
reg->idx[0].offset,
reg->idx[1].offset);
2879 "int(gl_LocalInvocationIndex)", gl_info);
2885 "gl_InvocationID", gl_info);
2889 sprintf(register_name,
"ivec3(gl_GlobalInvocationID)");
2893 sprintf(register_name,
"ivec3(gl_WorkGroupID)");
2897 sprintf(register_name,
"ivec3(gl_LocalInvocationID)");
2903 "phase_instance_id", gl_info);
2907 sprintf(register_name,
"gl_TessCoord");
2911 if (
reg->idx[0].rel_addr)
2913 if (
reg->idx[1].rel_addr)
2914 sprintf(register_name,
"shader_out[%s + %u].reg[%s + %u]",
2918 sprintf(register_name,
"shader_out[%s + %u].reg[%u]",
2920 reg->idx[1].offset);
2922 else if (
reg->idx[1].rel_addr)
2924 sprintf(register_name,
"shader_out[%u].reg[%s + %u]",
2926 reg->idx[1].offset);
2930 sprintf(register_name,
"shader_out[%u].reg[%u]",
2931 reg->idx[0].offset,
reg->idx[1].offset);
2937 sprintf(register_name,
"hs_out[%u]",
reg->idx[0].offset);
2939 sprintf(register_name,
"vpc[%u]",
reg->idx[0].offset);
2943 FIXME(
"Unhandled register type %#x.\n",
reg->type);
2944 sprintf(register_name,
"unrecognized_register");
2979 unsigned int size = 0;
2990 unsigned int component_idx)
2993 return (
swizzle >> (2 * component_idx)) & 0x3;
3001 const char *swizzle_chars = fixup ?
"zyxw" :
"xyzw";
3005 for (
i = 0;
i < 4; ++
i)
3017 *swizzle_str =
'\0';
3025 if (dst_data_type == src_data_type)
3033 switch (dst_data_type)
3060 FIXME(
"Unhandled cast from %#x to %#x.\n", src_data_type, dst_data_type);
3075 char swizzle_str[6];
3079 swizzle_str[0] =
'\0';
3084 switch (wined3d_src->
reg.type)
3087 param_data_type = data_type;
3129 glsl_dst->
reg_name, &is_color, ins);
3160 FIXME(
"Unhandled data type %#x.\n", data_type);
3184 modifiers = ins->
dst[0].modifiers;
3185 if (!modifiers)
return;
3198 FIXME(
"_centroid modifier not handled\n");
3218 FIXME(
"Unrecognized operator %#x.\n",
op);
3229 unsigned int *
coord_size,
unsigned int *deriv_size)
3250 && priv->
cur_ps_args->np2_fixup & (1u << resource_idx)
3255 const char *
base =
"texture", *
type_part =
"", *suffix =
"";
3258 sample_function->
data_type =
ctx->reg_maps->resource_info[resource_idx].data_type;
3263 ERR(
"Unexpected resource type %#x.\n", resource_type);
3273 switch (resource_type)
3285 grad = legacy_syntax =
TRUE;
3303 FIXME(
"Unhandled resource type %#x.\n", resource_type);
3310 FIXME(
"Unsupported grad function.\n");
3317 if (
flags & ~texel_fetch_flags)
3318 ERR(
"Unexpected flags %#x for texelFetch.\n",
flags & ~texel_fetch_flags);
3320 base =
"texelFetch";
3326 lod ?
"Lod" : grad ?
"Grad" :
"",
offset ?
"Offset" :
"", suffix);
3333 sample_function->
deriv_mask = (1u << deriv_size) - 1;
3348 switch(channel_source)
3351 strcat(arguments,
"0.0");
3355 strcat(arguments,
"1.0");
3379 FIXME(
"Unhandled channel source %#x\n", channel_source);
3380 strcat(arguments,
"undefined");
3384 if (sign_fixup)
strcat(arguments,
" * 2.0 - 1.0");
3390 unsigned int mask_size, remaining;
3391 DWORD fixup_mask = 0;
3392 char arguments[256];
3399 if (!(
mask &= fixup_mask))
3412 arguments[0] =
'\0';
3413 remaining = mask_size;
3417 if (--remaining)
strcat(arguments,
", ");
3422 if (--remaining)
strcat(arguments,
", ");
3427 if (--remaining)
strcat(arguments,
", ");
3432 if (--remaining)
strcat(arguments,
", ");
3453 const char *coord_reg_fmt, ...)
3457 char dst_swizzle[6];
3470 fixup = priv->
cur_ps_args->color_fixup[sampler_bind_idx];
3472 if (priv->
cur_ps_args->np2_fixup & (1u << sampler_bind_idx))
3482 if (sample_function->output_single_component)
3508 idx >> 1, (
idx % 2) ?
"z" :
"x");
3512 idx >> 1, (
idx % 2) ?
"zw" :
"xy");
3515 shader_addline(ins->ctx->buffer,
" * vec3(ps_samplerNP2Fixup[%u].%s, 1.0)",
3516 idx >> 1, (
idx % 2) ?
"zw" :
"xy");
3519 shader_addline(ins->ctx->buffer,
" * vec4(ps_samplerNP2Fixup[%u].%s, 1.0, 1.0)",
3520 idx >> 1, (
idx % 2) ?
"zw" :
"xy");
3524 if (sample_function->emulate_lod)
3527 switch (sample_function->emulate_lod)
3530 if (!
dx)
dx =
"vec2(0.0, 0.0)";
3531 if (!
dy)
dy =
"vec2(0.0, 0.0)";
3535 if (!
dx)
dx =
"vec3(0.0, 0.0, 0.0)";
3536 if (!
dy)
dy =
"vec3(0.0, 0.0, 0.0)";
3548 if (sample_function->offset_size)
3556 if (sample_function->output_single_component)
3614 op =
"<unhandled operator>";
3630 unsigned int mask_size;
3654 op =
"<unhandled operator>";
3677 op =
"<unhandled operator>";
3698 op =
"<unhandled operator>";
3699 ERR(
"Unhandled opcode %s.\n",
3719 FIXME(
"64-bit integer multiplies not implemented.\n");
3788 if (ins->
ctx->reg_maps->shader_version.major == 1
3794 if (mask_size > 1) {