ReactOS  0.4.14-dev-98-gb0d4763
shader_sm4.c
Go to the documentation of this file.
1 /*
2  * Copyright 2009 Henri Verbeet for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #include "config.h"
20 #include "wine/port.h"
21 
22 #include "wined3d_private.h"
23 
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
25 WINE_DECLARE_DEBUG_CHANNEL(d3d_bytecode);
26 
27 #define WINED3D_SM4_INSTRUCTION_MODIFIER (0x1u << 31)
28 
29 #define WINED3D_SM4_MODIFIER_AOFFIMMI 0x1
30 #define WINED3D_SM4_AOFFIMMI_U_SHIFT 9
31 #define WINED3D_SM4_AOFFIMMI_U_MASK (0xfu << WINED3D_SM4_AOFFIMMI_U_SHIFT)
32 #define WINED3D_SM4_AOFFIMMI_V_SHIFT 13
33 #define WINED3D_SM4_AOFFIMMI_V_MASK (0xfu << WINED3D_SM4_AOFFIMMI_V_SHIFT)
34 #define WINED3D_SM4_AOFFIMMI_W_SHIFT 17
35 #define WINED3D_SM4_AOFFIMMI_W_MASK (0xfu << WINED3D_SM4_AOFFIMMI_W_SHIFT)
36 
37 #define WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT 24
38 #define WINED3D_SM4_INSTRUCTION_LENGTH_MASK (0x1fu << WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT)
39 
40 #define WINED3D_SM4_INSTRUCTION_FLAGS_SHIFT 11
41 #define WINED3D_SM4_INSTRUCTION_FLAGS_MASK (0x7u << WINED3D_SM4_INSTRUCTION_FLAGS_SHIFT)
42 
43 #define WINED3D_SM4_RESOURCE_TYPE_SHIFT 11
44 #define WINED3D_SM4_RESOURCE_TYPE_MASK (0xfu << WINED3D_SM4_RESOURCE_TYPE_SHIFT)
45 
46 #define WINED3D_SM4_PRIMITIVE_TYPE_SHIFT 11
47 #define WINED3D_SM4_PRIMITIVE_TYPE_MASK (0x3fu << WINED3D_SM4_PRIMITIVE_TYPE_SHIFT)
48 
49 #define WINED3D_SM4_INDEX_TYPE_SHIFT 11
50 #define WINED3D_SM4_INDEX_TYPE_MASK (0x1u << WINED3D_SM4_INDEX_TYPE_SHIFT)
51 
52 #define WINED3D_SM4_SAMPLER_MODE_SHIFT 11
53 #define WINED3D_SM4_SAMPLER_MODE_MASK (0xfu << WINED3D_SM4_SAMPLER_MODE_SHIFT)
54 
55 #define WINED3D_SM4_SHADER_DATA_TYPE_SHIFT 11
56 #define WINED3D_SM4_SHADER_DATA_TYPE_MASK (0xfu << WINED3D_SM4_SHADER_DATA_TYPE_SHIFT)
57 
58 #define WINED3D_SM4_INTERPOLATION_MODE_SHIFT 11
59 #define WINED3D_SM4_INTERPOLATION_MODE_MASK (0xfu << WINED3D_SM4_INTERPOLATION_MODE_SHIFT)
60 
61 #define WINED3D_SM4_GLOBAL_FLAGS_SHIFT 11
62 #define WINED3D_SM4_GLOBAL_FLAGS_MASK (0xffu << WINED3D_SM4_GLOBAL_FLAGS_SHIFT)
63 
64 #define WINED3D_SM5_CONTROL_POINT_COUNT_SHIFT 11
65 #define WINED3D_SM5_CONTROL_POINT_COUNT_MASK (0xffu << WINED3D_SM5_CONTROL_POINT_COUNT_SHIFT)
66 
67 #define WINED3D_SM5_FP_ARRAY_SIZE_SHIFT 16
68 #define WINED3D_SM5_FP_TABLE_COUNT_MASK 0xffffu
69 
70 #define WINED3D_SM5_UAV_FLAGS_SHIFT 15
71 #define WINED3D_SM5_UAV_FLAGS_MASK (0x1ffu << WINED3D_SM5_UAV_FLAGS_SHIFT)
72 
73 #define WINED3D_SM5_SYNC_FLAGS_SHIFT 11
74 #define WINED3D_SM5_SYNC_FLAGS_MASK (0xffu << WINED3D_SM5_SYNC_FLAGS_SHIFT)
75 
76 #define WINED3D_SM5_TESSELLATOR_SHIFT 11
77 #define WINED3D_SM5_TESSELLATOR_MASK (0xfu << WINED3D_SM5_TESSELLATOR_SHIFT)
78 
79 #define WINED3D_SM4_OPCODE_MASK 0xff
80 
81 #define WINED3D_SM4_REGISTER_MODIFIER (0x1u << 31)
82 
83 #define WINED3D_SM4_ADDRESSING_SHIFT1 25
84 #define WINED3D_SM4_ADDRESSING_MASK1 (0x3u << WINED3D_SM4_ADDRESSING_SHIFT1)
85 
86 #define WINED3D_SM4_ADDRESSING_SHIFT0 22
87 #define WINED3D_SM4_ADDRESSING_MASK0 (0x3u << WINED3D_SM4_ADDRESSING_SHIFT0)
88 
89 #define WINED3D_SM4_REGISTER_ORDER_SHIFT 20
90 #define WINED3D_SM4_REGISTER_ORDER_MASK (0x3u << WINED3D_SM4_REGISTER_ORDER_SHIFT)
91 
92 #define WINED3D_SM4_REGISTER_TYPE_SHIFT 12
93 #define WINED3D_SM4_REGISTER_TYPE_MASK (0xffu << WINED3D_SM4_REGISTER_TYPE_SHIFT)
94 
95 #define WINED3D_SM4_SWIZZLE_TYPE_SHIFT 2
96 #define WINED3D_SM4_SWIZZLE_TYPE_MASK (0x3u << WINED3D_SM4_SWIZZLE_TYPE_SHIFT)
97 
98 #define WINED3D_SM4_IMMCONST_TYPE_SHIFT 0
99 #define WINED3D_SM4_IMMCONST_TYPE_MASK (0x3u << WINED3D_SM4_IMMCONST_TYPE_SHIFT)
100 
101 #define WINED3D_SM4_WRITEMASK_SHIFT 4
102 #define WINED3D_SM4_WRITEMASK_MASK (0xfu << WINED3D_SM4_WRITEMASK_SHIFT)
103 
104 #define WINED3D_SM4_SWIZZLE_SHIFT 4
105 #define WINED3D_SM4_SWIZZLE_MASK (0xffu << WINED3D_SM4_SWIZZLE_SHIFT)
106 
107 #define WINED3D_SM4_VERSION_MAJOR(version) (((version) >> 4) & 0xf)
108 #define WINED3D_SM4_VERSION_MINOR(version) (((version) >> 0) & 0xf)
109 
110 #define WINED3D_SM4_ADDRESSING_RELATIVE 0x2
111 #define WINED3D_SM4_ADDRESSING_OFFSET 0x1
112 
113 #define WINED3D_SM4_INSTRUCTION_FLAG_SATURATE 0x4
114 
115 #define WINED3D_SM4_CONDITIONAL_NZ (0x1u << 18)
116 
118 {
302 };
303 
305 {
339 };
340 
342 {
346 };
347 
349 {
387 };
388 
390 {
394 };
395 
397 {
400 };
401 
403 {
414 };
415 
417 {
423 };
424 
426 {
429 };
430 
432 {
435 };
436 
438 {
439  struct list entry;
441 };
442 
444 {
446  const DWORD *start, *end;
447 
448  unsigned int output_map[MAX_REG_OUTPUT];
449 
452  struct list src_free;
453  struct list src;
455 };
456 
458 {
461  const char *dst_info;
462  const char *src_info;
464  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
465  struct wined3d_sm4_data *priv);
466 };
467 
469 {
470  /* UNKNOWN */ WINED3D_PT_UNDEFINED,
471  /* WINED3D_SM4_OUTPUT_PT_POINTLIST */ WINED3D_PT_POINTLIST,
472  /* UNKNOWN */ WINED3D_PT_UNDEFINED,
473  /* WINED3D_SM4_OUTPUT_PT_LINESTRIP */ WINED3D_PT_LINESTRIP,
474  /* UNKNOWN */ WINED3D_PT_UNDEFINED,
475  /* WINED3D_SM4_OUTPUT_PT_TRIANGLESTRIP */ WINED3D_PT_TRIANGLESTRIP,
476 };
477 
479 {
480  /* UNKNOWN */ WINED3D_PT_UNDEFINED,
481  /* WINED3D_SM4_INPUT_PT_POINT */ WINED3D_PT_POINTLIST,
482  /* WINED3D_SM4_INPUT_PT_LINE */ WINED3D_PT_LINELIST,
483  /* WINED3D_SM4_INPUT_PT_TRIANGLE */ WINED3D_PT_TRIANGLELIST,
484  /* UNKNOWN */ WINED3D_PT_UNDEFINED,
485  /* UNKNOWN */ WINED3D_PT_UNDEFINED,
486  /* WINED3D_SM4_INPUT_PT_LINEADJ */ WINED3D_PT_LINELIST_ADJ,
487  /* WINED3D_SM4_INPUT_PT_TRIANGLEADJ */ WINED3D_PT_TRIANGLELIST_ADJ,
488 };
489 
491 {
493  /* WINED3D_SM4_RESOURCE_BUFFER */ WINED3D_SHADER_RESOURCE_BUFFER,
494  /* WINED3D_SM4_RESOURCE_TEXTURE_1D */ WINED3D_SHADER_RESOURCE_TEXTURE_1D,
495  /* WINED3D_SM4_RESOURCE_TEXTURE_2D */ WINED3D_SHADER_RESOURCE_TEXTURE_2D,
496  /* WINED3D_SM4_RESOURCE_TEXTURE_2DMS */ WINED3D_SHADER_RESOURCE_TEXTURE_2DMS,
497  /* WINED3D_SM4_RESOURCE_TEXTURE_3D */ WINED3D_SHADER_RESOURCE_TEXTURE_3D,
498  /* WINED3D_SM4_RESOURCE_TEXTURE_CUBE */ WINED3D_SHADER_RESOURCE_TEXTURE_CUBE,
499  /* WINED3D_SM4_RESOURCE_TEXTURE_1DARRAY */ WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY,
500  /* WINED3D_SM4_RESOURCE_TEXTURE_2DARRAY */ WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY,
501  /* WINED3D_SM4_RESOURCE_TEXTURE_2DMSARRAY */ WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY,
502  /* WINED3D_SM4_RESOURCE_TEXTURE_CUBEARRAY */ WINED3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY,
503 };
504 
505 static const enum wined3d_data_type data_type_table[] =
506 {
507  /* 0 */ WINED3D_DATA_FLOAT,
508  /* WINED3D_SM4_DATA_UNORM */ WINED3D_DATA_UNORM,
509  /* WINED3D_SM4_DATA_SNORM */ WINED3D_DATA_SNORM,
510  /* WINED3D_SM4_DATA_INT */ WINED3D_DATA_INT,
511  /* WINED3D_SM4_DATA_UINT */ WINED3D_DATA_UINT,
512  /* WINED3D_SM4_DATA_FLOAT */ WINED3D_DATA_FLOAT,
513 };
514 
515 static BOOL shader_sm4_read_src_param(struct wined3d_sm4_data *priv, const DWORD **ptr, const DWORD *end,
516  enum wined3d_data_type data_type, struct wined3d_shader_src_param *src_param);
517 static BOOL shader_sm4_read_dst_param(struct wined3d_sm4_data *priv, const DWORD **ptr, const DWORD *end,
518  enum wined3d_data_type data_type, struct wined3d_shader_dst_param *dst_param);
519 
521  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
522  struct wined3d_sm4_data *priv)
523 {
524  shader_sm4_read_src_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, &priv->src_param[0]);
525  ins->flags = (opcode_token & WINED3D_SM4_CONDITIONAL_NZ) ?
527 }
528 
530  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
531  struct wined3d_sm4_data *priv)
532 {
534  unsigned int icb_size;
535 
538  {
539  FIXME("Ignoring shader data type %#x.\n", type);
541  return;
542  }
543 
544  ++tokens;
545  icb_size = token_count - 1;
546  if (icb_size % 4 || icb_size > MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE)
547  {
548  FIXME("Unexpected immediate constant buffer size %u.\n", icb_size);
550  return;
551  }
552 
553  priv->icb.vec4_count = icb_size / 4;
554  memcpy(priv->icb.data, tokens, sizeof(*tokens) * icb_size);
555  ins->declaration.icb = &priv->icb;
556 }
557 
559  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
560  struct wined3d_sm4_data *priv)
561 {
562  enum wined3d_sm4_resource_type resource_type;
563  enum wined3d_sm4_data_type data_type;
564  enum wined3d_data_type reg_data_type;
566 
567  resource_type = (opcode_token & WINED3D_SM4_RESOURCE_TYPE_MASK) >> WINED3D_SM4_RESOURCE_TYPE_SHIFT;
568  if (!resource_type || (resource_type >= ARRAY_SIZE(resource_type_table)))
569  {
570  FIXME("Unhandled resource type %#x.\n", resource_type);
572  }
573  else
574  {
575  ins->declaration.semantic.resource_type = resource_type_table[resource_type];
576  }
578  shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], reg_data_type, &ins->declaration.semantic.reg);
579 
580  components = *tokens++;
581  if ((components & 0xfff0) != (components & 0xf) * 0x1110)
582  FIXME("Components (%#x) have different data types.\n", components);
583  data_type = components & 0xf;
584 
585  if (!data_type || (data_type >= ARRAY_SIZE(data_type_table)))
586  {
587  FIXME("Unhandled data type %#x.\n", data_type);
588  ins->declaration.semantic.resource_data_type = WINED3D_DATA_FLOAT;
589  }
590  else
591  {
592  ins->declaration.semantic.resource_data_type = data_type_table[data_type];
593  }
594 
595  if (reg_data_type == WINED3D_DATA_UAV)
597 }
598 
600  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
601  struct wined3d_sm4_data *priv)
602 {
603  shader_sm4_read_src_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_FLOAT, &ins->declaration.src);
604  if (opcode_token & WINED3D_SM4_INDEX_TYPE_MASK)
606 }
607 
609  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
610  struct wined3d_sm4_data *priv)
611 {
614  FIXME("Unhandled sampler mode %#x.\n", ins->flags);
615  shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_SAMPLER, &ins->declaration.dst);
616 }
617 
619  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
620  struct wined3d_sm4_data *priv)
621 {
622  shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_OPAQUE,
623  &ins->declaration.index_range.first_register);
624  ins->declaration.index_range.last_register = *tokens;
625 }
626 
628  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
629  struct wined3d_sm4_data *priv)
630 {
631  enum wined3d_sm4_output_primitive_type primitive_type;
632 
633  primitive_type = (opcode_token & WINED3D_SM4_PRIMITIVE_TYPE_MASK) >> WINED3D_SM4_PRIMITIVE_TYPE_SHIFT;
634  if (primitive_type >= ARRAY_SIZE(output_primitive_type_table))
636  else
637  ins->declaration.primitive_type.type = output_primitive_type_table[primitive_type];
638 
640  FIXME("Unhandled output primitive type %#x.\n", primitive_type);
641 }
642 
644  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
645  struct wined3d_sm4_data *priv)
646 {
647  enum wined3d_sm4_input_primitive_type primitive_type;
648 
649  primitive_type = (opcode_token & WINED3D_SM4_PRIMITIVE_TYPE_MASK) >> WINED3D_SM4_PRIMITIVE_TYPE_SHIFT;
650  if (WINED3D_SM5_INPUT_PT_PATCH1 <= primitive_type && primitive_type <= WINED3D_SM5_INPUT_PT_PATCH32)
651  {
653  ins->declaration.primitive_type.patch_vertex_count = primitive_type - WINED3D_SM5_INPUT_PT_PATCH1 + 1;
654  }
655  else if (primitive_type >= ARRAY_SIZE(input_primitive_type_table))
656  {
658  }
659  else
660  {
661  ins->declaration.primitive_type.type = input_primitive_type_table[primitive_type];
662  }
663 
665  FIXME("Unhandled input primitive type %#x.\n", primitive_type);
666 }
667 
669  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
670  struct wined3d_sm4_data *priv)
671 {
672  ins->declaration.count = *tokens;
673 }
674 
676  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
677  struct wined3d_sm4_data *priv)
678 {
679  shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_FLOAT, &ins->declaration.dst);
680 }
681 
683  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
684  struct wined3d_sm4_data *priv)
685 {
686  shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_FLOAT,
687  &ins->declaration.register_semantic.reg);
688  ins->declaration.register_semantic.sysval_semantic = *tokens;
689 }
690 
692  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
693  struct wined3d_sm4_data *priv)
694 {
696  shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_FLOAT, &ins->declaration.dst);
697 }
698 
700  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
701  struct wined3d_sm4_data *priv)
702 {
704  shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_FLOAT,
705  &ins->declaration.register_semantic.reg);
706  ins->declaration.register_semantic.sysval_semantic = *tokens;
707 }
708 
710  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
711  struct wined3d_sm4_data *priv)
712 {
713  ins->declaration.indexable_temp.register_idx = *tokens++;
714  ins->declaration.indexable_temp.register_size = *tokens++;
715  ins->declaration.indexable_temp.component_count = *tokens;
716 }
717 
719  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
720  struct wined3d_sm4_data *priv)
721 {
723 }
724 
726  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
727  struct wined3d_sm4_data *priv)
728 {
729  priv->src_param[0].reg.u.fp_body_idx = *tokens++;
730  shader_sm4_read_src_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_OPAQUE, &priv->src_param[0]);
731 }
732 
734  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
735  struct wined3d_sm4_data *priv)
736 {
737  ins->declaration.index = *tokens;
738 }
739 
741  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
742  struct wined3d_sm4_data *priv)
743 {
744  ins->declaration.index = *tokens++;
745  FIXME("Ignoring set of function bodies (count %u).\n", *tokens);
746 }
747 
749  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
750  struct wined3d_sm4_data *priv)
751 {
752  ins->declaration.fp.index = *tokens++;
753  ins->declaration.fp.body_count = *tokens++;
754  ins->declaration.fp.array_size = *tokens >> WINED3D_SM5_FP_ARRAY_SIZE_SHIFT;
755  ins->declaration.fp.table_count = *tokens++ & WINED3D_SM5_FP_TABLE_COUNT_MASK;
756  FIXME("Ignoring set of function tables (count %u).\n", ins->declaration.fp.table_count);
757 }
758 
760  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
761  struct wined3d_sm4_data *priv)
762 {
765 }
766 
768  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
769  struct wined3d_sm4_data *priv)
770 {
773 }
774 
776  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
777  struct wined3d_sm4_data *priv)
778 {
781 }
782 
784  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
785  struct wined3d_sm4_data *priv)
786 {
789 }
790 
792  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
793  struct wined3d_sm4_data *priv)
794 {
795  ins->declaration.max_tessellation_factor = *(float *)tokens;
796 }
797 
799  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
800  struct wined3d_sm4_data *priv)
801 {
802  ins->declaration.thread_group_size.x = *tokens++;
803  ins->declaration.thread_group_size.y = *tokens++;
804  ins->declaration.thread_group_size.z = *tokens++;
805 }
806 
808  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
809  struct wined3d_sm4_data *priv)
810 {
811  shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UAV, &ins->declaration.dst);
813 }
814 
816  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
817  struct wined3d_sm4_data *priv)
818 {
819  shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UAV,
820  &ins->declaration.structured_resource.reg);
822  ins->declaration.structured_resource.byte_stride = *tokens;
823  if (ins->declaration.structured_resource.byte_stride % 4)
824  FIXME("Byte stride %u is not multiple of 4.\n", ins->declaration.structured_resource.byte_stride);
825 }
826 
828  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
829  struct wined3d_sm4_data *priv)
830 {
831  shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_FLOAT, &ins->declaration.tgsm_raw.reg);
832  ins->declaration.tgsm_raw.byte_count = *tokens;
833  if (ins->declaration.tgsm_raw.byte_count % 4)
834  FIXME("Byte count %u is not multiple of 4.\n", ins->declaration.tgsm_raw.byte_count);
835 }
836 
838  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
839  struct wined3d_sm4_data *priv)
840 {
841  shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_FLOAT,
842  &ins->declaration.tgsm_structured.reg);
843  ins->declaration.tgsm_structured.byte_stride = *tokens++;
844  ins->declaration.tgsm_structured.structure_count = *tokens;
845  if (ins->declaration.tgsm_structured.byte_stride % 4)
846  FIXME("Byte stride %u is not multiple of 4.\n", ins->declaration.tgsm_structured.byte_stride);
847 }
848 
850  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
851  struct wined3d_sm4_data *priv)
852 {
853  shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_RESOURCE,
854  &ins->declaration.structured_resource.reg);
855  ins->declaration.structured_resource.byte_stride = *tokens;
856  if (ins->declaration.structured_resource.byte_stride % 4)
857  FIXME("Byte stride %u is not multiple of 4.\n", ins->declaration.structured_resource.byte_stride);
858 }
859 
861  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
862  struct wined3d_sm4_data *priv)
863 {
864  shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_RESOURCE, &ins->declaration.dst);
865 }
866 
868  DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
869  struct wined3d_sm4_data *priv)
870 {
872 }
873 
874 /*
875  * f -> WINED3D_DATA_FLOAT
876  * i -> WINED3D_DATA_INT
877  * u -> WINED3D_DATA_UINT
878  * O -> WINED3D_DATA_OPAQUE
879  * R -> WINED3D_DATA_RESOURCE
880  * S -> WINED3D_DATA_SAMPLER
881  * U -> WINED3D_DATA_UAV
882  */
883 static const struct wined3d_sm4_opcode_info opcode_table[] =
884 {
885  {WINED3D_SM4_OP_ADD, WINED3DSIH_ADD, "f", "ff"},
886  {WINED3D_SM4_OP_AND, WINED3DSIH_AND, "u", "uu"},
900  {WINED3D_SM4_OP_DIV, WINED3DSIH_DIV, "f", "ff"},
901  {WINED3D_SM4_OP_DP2, WINED3DSIH_DP2, "f", "ff"},
902  {WINED3D_SM4_OP_DP3, WINED3DSIH_DP3, "f", "ff"},
903  {WINED3D_SM4_OP_DP4, WINED3DSIH_DP4, "f", "ff"},
909  {WINED3D_SM4_OP_EQ, WINED3DSIH_EQ, "u", "ff"},
910  {WINED3D_SM4_OP_EXP, WINED3DSIH_EXP, "f", "f"},
911  {WINED3D_SM4_OP_FRC, WINED3DSIH_FRC, "f", "f"},
914  {WINED3D_SM4_OP_GE, WINED3DSIH_GE, "u", "ff"},
915  {WINED3D_SM4_OP_IADD, WINED3DSIH_IADD, "i", "ii"},
916  {WINED3D_SM4_OP_IF, WINED3DSIH_IF, "", "u",
918  {WINED3D_SM4_OP_IEQ, WINED3DSIH_IEQ, "u", "ii"},
919  {WINED3D_SM4_OP_IGE, WINED3DSIH_IGE, "u", "ii"},
920  {WINED3D_SM4_OP_ILT, WINED3DSIH_ILT, "u", "ii"},
921  {WINED3D_SM4_OP_IMAD, WINED3DSIH_IMAD, "i", "iii"},
922  {WINED3D_SM4_OP_IMAX, WINED3DSIH_IMAX, "i", "ii"},
923  {WINED3D_SM4_OP_IMIN, WINED3DSIH_IMIN, "i", "ii"},
924  {WINED3D_SM4_OP_IMUL, WINED3DSIH_IMUL, "ii", "ii"},
925  {WINED3D_SM4_OP_INE, WINED3DSIH_INE, "u", "ii"},
927  {WINED3D_SM4_OP_ISHL, WINED3DSIH_ISHL, "i", "ii"},
928  {WINED3D_SM4_OP_ISHR, WINED3DSIH_ISHR, "i", "ii"},
931  {WINED3D_SM4_OP_LD, WINED3DSIH_LD, "u", "iR"},
933  {WINED3D_SM4_OP_LOG, WINED3DSIH_LOG, "f", "f"},
935  {WINED3D_SM4_OP_LT, WINED3DSIH_LT, "u", "ff"},
936  {WINED3D_SM4_OP_MAD, WINED3DSIH_MAD, "f", "fff"},
937  {WINED3D_SM4_OP_MIN, WINED3DSIH_MIN, "f", "ff"},
938  {WINED3D_SM4_OP_MAX, WINED3DSIH_MAX, "f", "ff"},
941  {WINED3D_SM4_OP_MOV, WINED3DSIH_MOV, "f", "f"},
942  {WINED3D_SM4_OP_MOVC, WINED3DSIH_MOVC, "f", "uff"},
943  {WINED3D_SM4_OP_MUL, WINED3DSIH_MUL, "f", "ff"},
944  {WINED3D_SM4_OP_NE, WINED3DSIH_NE, "u", "ff"},
946  {WINED3D_SM4_OP_NOT, WINED3DSIH_NOT, "u", "u"},
947  {WINED3D_SM4_OP_OR, WINED3DSIH_OR, "u", "uu"},
956  {WINED3D_SM4_OP_RSQ, WINED3DSIH_RSQ, "f", "f"},
966  {WINED3D_SM4_OP_UDIV, WINED3DSIH_UDIV, "uu", "uu"},
967  {WINED3D_SM4_OP_ULT, WINED3DSIH_ULT, "u", "uu"},
968  {WINED3D_SM4_OP_UGE, WINED3DSIH_UGE, "u", "uu"},
969  {WINED3D_SM4_OP_UMUL, WINED3DSIH_UMUL, "uu", "uu"},
970  {WINED3D_SM4_OP_UMAX, WINED3DSIH_UMAX, "u", "uu"},
971  {WINED3D_SM4_OP_UMIN, WINED3DSIH_UMIN, "u", "uu"},
972  {WINED3D_SM4_OP_USHR, WINED3DSIH_USHR, "u", "uu"},
974  {WINED3D_SM4_OP_XOR, WINED3DSIH_XOR, "u", "uu"},
1011  {WINED3D_SM4_OP_LOD, WINED3DSIH_LOD, "f", "fRS"},
1031  {WINED3D_SM5_OP_RCP, WINED3DSIH_RCP, "f", "f"},
1038  {WINED3D_SM5_OP_UBFE, WINED3DSIH_UBFE, "u", "iiu"},
1039  {WINED3D_SM5_OP_IBFE, WINED3DSIH_IBFE, "i", "iii"},
1040  {WINED3D_SM5_OP_BFI, WINED3DSIH_BFI, "u", "iiuu"},
1042  {WINED3D_SM5_OP_SWAPC, WINED3DSIH_SWAPC, "ff", "uff"},
1114 };
1115 
1117 {
1118  /* WINED3D_SM4_RT_TEMP */ WINED3DSPR_TEMP,
1119  /* WINED3D_SM4_RT_INPUT */ WINED3DSPR_INPUT,
1120  /* WINED3D_SM4_RT_OUTPUT */ WINED3DSPR_OUTPUT,
1121  /* WINED3D_SM4_RT_INDEXABLE_TEMP */ WINED3DSPR_IDXTEMP,
1122  /* WINED3D_SM4_RT_IMMCONST */ WINED3DSPR_IMMCONST,
1123  /* UNKNOWN */ ~0u,
1124  /* WINED3D_SM4_RT_SAMPLER */ WINED3DSPR_SAMPLER,
1125  /* WINED3D_SM4_RT_RESOURCE */ WINED3DSPR_RESOURCE,
1126  /* WINED3D_SM4_RT_CONSTBUFFER */ WINED3DSPR_CONSTBUFFER,
1127  /* WINED3D_SM4_RT_IMMCONSTBUFFER */ WINED3DSPR_IMMCONSTBUFFER,
1128  /* UNKNOWN */ ~0u,
1129  /* WINED3D_SM4_RT_PRIMID */ WINED3DSPR_PRIMID,
1130  /* WINED3D_SM4_RT_DEPTHOUT */ WINED3DSPR_DEPTHOUT,
1131  /* WINED3D_SM4_RT_NULL */ WINED3DSPR_NULL,
1132  /* UNKNOWN */ ~0u,
1133  /* WINED3D_SM4_RT_OMASK */ WINED3DSPR_SAMPLEMASK,
1134  /* WINED3D_SM5_RT_STREAM */ WINED3DSPR_STREAM,
1135  /* WINED3D_SM5_RT_FUNCTION_BODY */ WINED3DSPR_FUNCTIONBODY,
1136  /* UNKNOWN */ ~0u,
1137  /* WINED3D_SM5_RT_FUNCTION_POINTER */ WINED3DSPR_FUNCTIONPOINTER,
1138  /* UNKNOWN */ ~0u,
1139  /* UNKNOWN */ ~0u,
1140  /* WINED3D_SM5_RT_OUTPUT_CONTROL_POINT_ID */ WINED3DSPR_OUTPOINTID,
1141  /* WINED3D_SM5_RT_FORK_INSTANCE_ID */ WINED3DSPR_FORKINSTID,
1142  /* WINED3D_SM5_RT_JOIN_INSTANCE_ID */ WINED3DSPR_JOININSTID,
1143  /* WINED3D_SM5_RT_INPUT_CONTROL_POINT */ WINED3DSPR_INCONTROLPOINT,
1144  /* WINED3D_SM5_RT_OUTPUT_CONTROL_POINT */ WINED3DSPR_OUTCONTROLPOINT,
1145  /* WINED3D_SM5_RT_PATCH_CONSTANT_DATA */ WINED3DSPR_PATCHCONST,
1146  /* WINED3D_SM5_RT_DOMAIN_LOCATION */ WINED3DSPR_TESSCOORD,
1147  /* UNKNOWN */ ~0u,
1148  /* WINED3D_SM5_RT_UAV */ WINED3DSPR_UAV,
1149  /* WINED3D_SM5_RT_SHARED_MEMORY */ WINED3DSPR_GROUPSHAREDMEM,
1150  /* WINED3D_SM5_RT_THREAD_ID */ WINED3DSPR_THREADID,
1151  /* WINED3D_SM5_RT_THREAD_GROUP_ID */ WINED3DSPR_THREADGROUPID,
1152  /* WINED3D_SM5_RT_LOCAL_THREAD_ID */ WINED3DSPR_LOCALTHREADID,
1153  /* WINED3D_SM5_RT_COVERAGE */ WINED3DSPR_COVERAGE,
1154  /* WINED3D_SM5_RT_LOCAL_THREAD_INDEX */ WINED3DSPR_LOCALTHREADINDEX,
1155  /* WINED3D_SM5_RT_GS_INSTANCE_ID */ WINED3DSPR_GSINSTID,
1156  /* WINED3D_SM5_RT_DEPTHOUT_GREATER_EQUAL */ WINED3DSPR_DEPTHOUTGE,
1157  /* WINED3D_SM5_RT_DEPTHOUT_LESS_EQUAL */ WINED3DSPR_DEPTHOUTLE,
1158 };
1159 
1161 {
1162  unsigned int i;
1163 
1164  for (i = 0; i < ARRAY_SIZE(opcode_table); ++i)
1165  {
1166  if (opcode == opcode_table[i].opcode) return &opcode_table[i];
1167  }
1168 
1169  return NULL;
1170 }
1171 
1172 static void map_register(const struct wined3d_sm4_data *priv, struct wined3d_shader_register *reg)
1173 {
1174  switch (priv->shader_version.type)
1175  {
1177  if (reg->type == WINED3DSPR_OUTPUT)
1178  {
1179  unsigned int reg_idx = reg->idx[0].offset;
1180 
1181  if (reg_idx >= ARRAY_SIZE(priv->output_map))
1182  {
1183  ERR("Invalid output index %u.\n", reg_idx);
1184  break;
1185  }
1186 
1187  reg->type = WINED3DSPR_COLOROUT;
1188  reg->idx[0].offset = priv->output_map[reg_idx];
1189  }
1190  break;
1191 
1192  default:
1193  break;
1194  }
1195 }
1196 
1198 {
1199  switch (t)
1200  {
1201  case 'f':
1202  return WINED3D_DATA_FLOAT;
1203  case 'i':
1204  return WINED3D_DATA_INT;
1205  case 'u':
1206  return WINED3D_DATA_UINT;
1207  case 'O':
1208  return WINED3D_DATA_OPAQUE;
1209  case 'R':
1210  return WINED3D_DATA_RESOURCE;
1211  case 'S':
1212  return WINED3D_DATA_SAMPLER;
1213  case 'U':
1214  return WINED3D_DATA_UAV;
1215  default:
1216  ERR("Invalid data type '%c'.\n", t);
1217  return WINED3D_DATA_FLOAT;
1218  }
1219 }
1220 
1221 static void *shader_sm4_init(const DWORD *byte_code, size_t byte_code_size,
1222  const struct wined3d_shader_signature *output_signature)
1223 {
1224  DWORD version_token, token_count;
1225  struct wined3d_sm4_data *priv;
1226  unsigned int i;
1227 
1228  if (byte_code_size / sizeof(*byte_code) < 2)
1229  {
1230  WARN("Invalid byte code size %lu.\n", (long)byte_code_size);
1231  return NULL;
1232  }
1233 
1234  version_token = byte_code[0];
1235  TRACE("Version: 0x%08x.\n", version_token);
1236  token_count = byte_code[1];
1237  TRACE("Token count: %u.\n", token_count);
1238 
1239  if (token_count < 2 || byte_code_size / sizeof(*byte_code) < token_count)
1240  {
1241  WARN("Invalid token count %u.\n", token_count);
1242  return NULL;
1243  }
1244 
1245  if (!(priv = heap_alloc(sizeof(*priv))))
1246  {
1247  ERR("Failed to allocate private data\n");
1248  return NULL;
1249  }
1250 
1251  priv->start = &byte_code[2];
1252  priv->end = &byte_code[token_count];
1253 
1254  switch (version_token >> 16)
1255  {
1256  case WINED3D_SM4_PS:
1258  break;
1259 
1260  case WINED3D_SM4_VS:
1262  break;
1263 
1264  case WINED3D_SM4_GS:
1266  break;
1267 
1268  case WINED3D_SM5_HS:
1270  break;
1271 
1272  case WINED3D_SM5_DS:
1274  break;
1275 
1276  case WINED3D_SM5_CS:
1278  break;
1279 
1280  default:
1281  FIXME("Unrecognised shader type %#x.\n", version_token >> 16);
1282  }
1283  priv->shader_version.major = WINED3D_SM4_VERSION_MAJOR(version_token);
1284  priv->shader_version.minor = WINED3D_SM4_VERSION_MINOR(version_token);
1285 
1286  memset(priv->output_map, 0xff, sizeof(priv->output_map));
1287  for (i = 0; i < output_signature->element_count; ++i)
1288  {
1289  struct wined3d_shader_signature_element *e = &output_signature->elements[i];
1290 
1291  if (e->register_idx >= ARRAY_SIZE(priv->output_map))
1292  {
1293  WARN("Invalid output index %u.\n", e->register_idx);
1294  continue;
1295  }
1296 
1297  priv->output_map[e->register_idx] = e->semantic_idx;
1298  }
1299 
1300  list_init(&priv->src_free);
1301  list_init(&priv->src);
1302 
1303  return priv;
1304 }
1305 
1306 static void shader_sm4_free(void *data)
1307 {
1308  struct wined3d_shader_src_param_entry *e1, *e2;
1309  struct wined3d_sm4_data *priv = data;
1310 
1311  list_move_head(&priv->src_free, &priv->src);
1313  {
1314  heap_free(e1);
1315  }
1316  heap_free(priv);
1317 }
1318 
1320 {
1322  struct list *elem;
1323 
1324  if (!list_empty(&priv->src_free))
1325  {
1326  elem = list_head(&priv->src_free);
1327  list_remove(elem);
1328  }
1329  else
1330  {
1331  if (!(e = heap_alloc(sizeof(*e))))
1332  return NULL;
1333  elem = &e->entry;
1334  }
1335 
1336  list_add_tail(&priv->src, elem);
1338  return &e->param;
1339 }
1340 
1341 static void shader_sm4_read_header(void *data, const DWORD **ptr, struct wined3d_shader_version *shader_version)
1342 {
1343  struct wined3d_sm4_data *priv = data;
1344 
1345  *ptr = priv->start;
1346  *shader_version = priv->shader_version;
1347 }
1348 
1349 static BOOL shader_sm4_read_reg_idx(struct wined3d_sm4_data *priv, const DWORD **ptr, const DWORD *end,
1350  DWORD addressing, struct wined3d_shader_register_index *reg_idx)
1351 {
1352  if (addressing & WINED3D_SM4_ADDRESSING_RELATIVE)
1353  {
1354  struct wined3d_shader_src_param *rel_addr = get_src_param(priv);
1355 
1356  if (!(reg_idx->rel_addr = rel_addr))
1357  {
1358  ERR("Failed to get src param for relative addressing.\n");
1359  return FALSE;
1360  }
1361 
1362  if (addressing & WINED3D_SM4_ADDRESSING_OFFSET)
1363  reg_idx->offset = *(*ptr)++;
1364  else
1365  reg_idx->offset = 0;
1367  }
1368  else
1369  {
1370  reg_idx->rel_addr = NULL;
1371  reg_idx->offset = *(*ptr)++;
1372  }
1373 
1374  return TRUE;
1375 }
1376 
1377 static BOOL shader_sm4_read_param(struct wined3d_sm4_data *priv, const DWORD **ptr, const DWORD *end,
1378  enum wined3d_data_type data_type, struct wined3d_shader_register *param,
1379  enum wined3d_shader_src_modifier *modifier)
1380 {
1381  enum wined3d_sm4_register_type register_type;
1382  DWORD token, order;
1383 
1384  if (*ptr >= end)
1385  {
1386  WARN("Invalid ptr %p >= end %p.\n", *ptr, end);
1387  return FALSE;
1388  }
1389  token = *(*ptr)++;
1390 
1392  if (register_type >= ARRAY_SIZE(register_type_table)
1393  || register_type_table[register_type] == ~0u)
1394  {
1395  FIXME("Unhandled register type %#x.\n", register_type);
1396  param->type = WINED3DSPR_TEMP;
1397  }
1398  else
1399  {
1400  param->type = register_type_table[register_type];
1401  }
1402  param->data_type = data_type;
1403 
1405  {
1406  DWORD m;
1407 
1408  if (*ptr >= end)
1409  {
1410  WARN("Invalid ptr %p >= end %p.\n", *ptr, end);
1411  return FALSE;
1412  }
1413  m = *(*ptr)++;
1414 
1415  switch (m)
1416  {
1417  case 0x41:
1418  *modifier = WINED3DSPSM_NEG;
1419  break;
1420 
1421  case 0x81:
1422  *modifier = WINED3DSPSM_ABS;
1423  break;
1424 
1425  case 0xc1:
1426  *modifier = WINED3DSPSM_ABSNEG;
1427  break;
1428 
1429  default:
1430  FIXME("Skipping modifier 0x%08x.\n", m);
1431  *modifier = WINED3DSPSM_NONE;
1432  break;
1433  }
1434  }
1435  else
1436  {
1437  *modifier = WINED3DSPSM_NONE;
1438  }
1439 
1441 
1442  if (order < 1)
1443  param->idx[0].offset = ~0U;
1444  else
1445  {
1447  if (!(shader_sm4_read_reg_idx(priv, ptr, end, addressing, &param->idx[0])))
1448  {
1449  ERR("Failed to read register index.\n");
1450  return FALSE;
1451  }
1452  }
1453 
1454  if (order < 2)
1455  param->idx[1].offset = ~0U;
1456  else
1457  {
1459  if (!(shader_sm4_read_reg_idx(priv, ptr, end, addressing, &param->idx[1])))
1460  {
1461  ERR("Failed to read register index.\n");
1462  return FALSE;
1463  }
1464  }
1465 
1466  if (order > 2)
1467  FIXME("Unhandled order %u.\n", order);
1468 
1469  if (register_type == WINED3D_SM4_RT_IMMCONST)
1470  {
1471  enum wined3d_sm4_immconst_type immconst_type =
1473 
1474  switch (immconst_type)
1475  {
1477  param->immconst_type = WINED3D_IMMCONST_SCALAR;
1478  if (end - *ptr < 1)
1479  {
1480  WARN("Invalid ptr %p, end %p.\n", *ptr, end);
1481  return FALSE;
1482  }
1483  memcpy(param->u.immconst_data, *ptr, 1 * sizeof(DWORD));
1484  *ptr += 1;
1485  break;
1486 
1488  param->immconst_type = WINED3D_IMMCONST_VEC4;
1489  if (end - *ptr < 4)
1490  {
1491  WARN("Invalid ptr %p, end %p.\n", *ptr, end);
1492  return FALSE;
1493  }
1494  memcpy(param->u.immconst_data, *ptr, 4 * sizeof(DWORD));
1495  *ptr += 4;
1496  break;
1497 
1498  default:
1499  FIXME("Unhandled immediate constant type %#x.\n", immconst_type);
1500  break;
1501  }
1502  }
1503 
1504  map_register(priv, param);
1505 
1506  return TRUE;
1507 }
1508 
1509 static BOOL shader_sm4_read_src_param(struct wined3d_sm4_data *priv, const DWORD **ptr, const DWORD *end,
1510  enum wined3d_data_type data_type, struct wined3d_shader_src_param *src_param)
1511 {
1512  DWORD token;
1513 
1514  if (*ptr >= end)
1515  {
1516  WARN("Invalid ptr %p >= end %p.\n", *ptr, end);
1517  return FALSE;
1518  }
1519  token = **ptr;
1520 
1521  if (!shader_sm4_read_param(priv, ptr, end, data_type, &src_param->reg, &src_param->modifiers))
1522  {
1523  ERR("Failed to read parameter.\n");
1524  return FALSE;
1525  }
1526 
1527  if (src_param->reg.type == WINED3DSPR_IMMCONST)
1528  {
1529  src_param->swizzle = WINED3DSP_NOSWIZZLE;
1530  }
1531  else
1532  {
1533  enum wined3d_sm4_swizzle_type swizzle_type =
1535 
1536  switch (swizzle_type)
1537  {
1539  src_param->swizzle = WINED3DSP_NOSWIZZLE;
1540  break;
1541 
1544  src_param->swizzle = (src_param->swizzle & 0x3) * 0x55;
1545  break;
1546 
1549  break;
1550 
1551  default:
1552  FIXME("Unhandled swizzle type %#x.\n", swizzle_type);
1553  break;
1554  }
1555  }
1556 
1557  return TRUE;
1558 }
1559 
1560 static BOOL shader_sm4_read_dst_param(struct wined3d_sm4_data *priv, const DWORD **ptr, const DWORD *end,
1561  enum wined3d_data_type data_type, struct wined3d_shader_dst_param *dst_param)
1562 {
1563  enum wined3d_shader_src_modifier modifier;
1564  DWORD token;
1565 
1566  if (*ptr >= end)
1567  {
1568  WARN("Invalid ptr %p >= end %p.\n", *ptr, end);
1569  return FALSE;
1570  }
1571  token = **ptr;
1572 
1573  if (!shader_sm4_read_param(priv, ptr, end, data_type, &dst_param->reg, &modifier))
1574  {
1575  ERR("Failed to read parameter.\n");
1576  return FALSE;
1577  }
1578 
1579  if (modifier != WINED3DSPSM_NONE)
1580  {
1581  ERR("Invalid source modifier %#x on destination register.\n", modifier);
1582  return FALSE;
1583  }
1584 
1586  dst_param->modifiers = 0;
1587  dst_param->shift = 0;
1588 
1589  return TRUE;
1590 }
1591 
1593 {
1594  static const DWORD recognized_bits = WINED3D_SM4_INSTRUCTION_MODIFIER
1599 
1600  if (modifier & ~recognized_bits)
1601  {
1602  FIXME("Unhandled modifier 0x%08x.\n", modifier);
1603  }
1604  else
1605  {
1606  /* Bit fields are used for sign extension */
1607  struct
1608  {
1609  int u : 4;
1610  int v : 4;
1611  int w : 4;
1612  }
1613  aoffimmi;
1614  aoffimmi.u = (modifier & WINED3D_SM4_AOFFIMMI_U_MASK) >> WINED3D_SM4_AOFFIMMI_U_SHIFT;
1615  aoffimmi.v = (modifier & WINED3D_SM4_AOFFIMMI_V_MASK) >> WINED3D_SM4_AOFFIMMI_V_SHIFT;
1616  aoffimmi.w = (modifier & WINED3D_SM4_AOFFIMMI_W_MASK) >> WINED3D_SM4_AOFFIMMI_W_SHIFT;
1617  ins->texel_offset.u = aoffimmi.u;
1618  ins->texel_offset.v = aoffimmi.v;
1619  ins->texel_offset.w = aoffimmi.w;
1620  }
1621 }
1622 
1623 static void shader_sm4_read_instruction(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins)
1624 {
1625  const struct wined3d_sm4_opcode_info *opcode_info;
1626  DWORD opcode_token, opcode, previous_token;
1627  struct wined3d_sm4_data *priv = data;
1628  unsigned int i, len;
1629  SIZE_T remaining;
1630  const DWORD *p;
1631 
1632  list_move_head(&priv->src_free, &priv->src);
1633 
1634  if (*ptr >= priv->end)
1635  {
1636  WARN("End of byte-code, failed to read opcode.\n");
1637  goto fail;
1638  }
1639  remaining = priv->end - *ptr;
1640 
1641  opcode_token = *(*ptr)++;
1642  opcode = opcode_token & WINED3D_SM4_OPCODE_MASK;
1643 
1645  if (!len)
1646  {
1647  if (remaining < 2)
1648  {
1649  WARN("End of byte-code, failed to read length token.\n");
1650  goto fail;
1651  }
1652  len = **ptr;
1653  }
1654  if (!len || remaining < len)
1655  {
1656  WARN("Read invalid length %u (remaining %lu).\n", len, remaining);
1657  goto fail;
1658  }
1659  --len;
1660 
1661  if (TRACE_ON(d3d_bytecode))
1662  {
1663  TRACE_(d3d_bytecode)("[ %08x ", opcode_token);
1664  for (i = 0; i < len; ++i)
1665  {
1666  TRACE_(d3d_bytecode)("%08x ", (*ptr)[i]);
1667  }
1668  TRACE_(d3d_bytecode)("]\n");
1669  }
1670 
1671  if (!(opcode_info = get_opcode_info(opcode)))
1672  {
1673  FIXME("Unrecognized opcode %#x, opcode_token 0x%08x.\n", opcode, opcode_token);
1675  *ptr += len;
1676  return;
1677  }
1678 
1679  ins->handler_idx = opcode_info->handler_idx;
1680  ins->flags = 0;
1681  ins->coissue = 0;
1682  ins->predicate = NULL;
1683  ins->dst_count = strlen(opcode_info->dst_info);
1684  ins->dst = priv->dst_param;
1685  ins->src_count = strlen(opcode_info->src_info);
1686  ins->src = priv->src_param;
1687  memset(&ins->texel_offset, 0, sizeof(ins->texel_offset));
1688 
1689  p = *ptr;
1690  *ptr += len;
1691 
1692  if (opcode_info->read_opcode_func)
1693  {
1694  opcode_info->read_opcode_func(ins, opcode, opcode_token, p, len, priv);
1695  }
1696  else
1697  {
1698  enum wined3d_shader_dst_modifier instruction_dst_modifier = WINED3DSPDM_NONE;
1699 
1700  previous_token = opcode_token;
1701  while (previous_token & WINED3D_SM4_INSTRUCTION_MODIFIER && p != *ptr)
1702  shader_sm4_read_instruction_modifier(previous_token = *p++, ins);
1703 
1705 
1707  {
1709  instruction_dst_modifier = WINED3DSPDM_SATURATE;
1710  }
1711 
1712  for (i = 0; i < ins->dst_count; ++i)
1713  {
1714  if (!(shader_sm4_read_dst_param(priv, &p, *ptr, map_data_type(opcode_info->dst_info[i]),
1715  &priv->dst_param[i])))
1716  {
1718  return;
1719  }
1720  priv->dst_param[i].modifiers |= instruction_dst_modifier;
1721  }
1722 
1723  for (i = 0; i < ins->src_count; ++i)
1724  {
1725  if (!(shader_sm4_read_src_param(priv, &p, *ptr, map_data_type(opcode_info->src_info[i]),
1726  &priv->src_param[i])))
1727  {
1729  return;
1730  }
1731  }
1732  }
1733 
1734  return;
1735 
1736 fail:
1737  *ptr = priv->end;
1739  return;
1740 }
1741 
1742 static BOOL shader_sm4_is_end(void *data, const DWORD **ptr)
1743 {
1744  struct wined3d_sm4_data *priv = data;
1745  return *ptr == priv->end;
1746 }
1747 
1749 {
1755 };
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
static void shader_sm4_read_dcl_global_flags(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:718
unsigned int output_map[MAX_REG_OUTPUT]
Definition: shader_sm4.c:448
static void shader_sm4_read_declaration_count(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:668
struct wined3d_shader_dst_param dst_param[2]
Definition: shader_sm4.c:451
#define WINED3D_SM4_RESOURCE_TYPE_MASK
Definition: shader_sm4.c:44
#define WINED3D_SM4_PRIMITIVE_TYPE_MASK
Definition: shader_sm4.c:47
#define WINED3D_SM5_TESSELLATOR_MASK
Definition: shader_sm4.c:77
GLuint GLdouble GLdouble GLint GLint order
Definition: glext.h:11194
#define WINED3D_SM4_SWIZZLE_MASK
Definition: shader_sm4.c:105
#define TRUE
Definition: types.h:120
static void shader_sm5_read_dcl_interface(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:748
#define WINED3D_SM4_REGISTER_ORDER_SHIFT
Definition: shader_sm4.c:89
#define WINED3D_SM5_CS
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define WINED3D_SM4_REGISTER_TYPE_SHIFT
Definition: shader_sm4.c:92
#define WINED3D_SM4_INSTRUCTION_MODIFIER
Definition: shader_sm4.c:27
const struct wined3d_shader_immediate_constant_buffer * icb
struct wined3d_shader_src_param src_param[5]
Definition: shader_sm4.c:450
#define WINED3D_SM4_PRIMITIVE_TYPE_SHIFT
Definition: shader_sm4.c:46
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define WINED3D_SM4_WRITEMASK_MASK
Definition: shader_sm4.c:102
wined3d_sm4_sampler_mode
Definition: shader_sm4.c:425
struct wined3d_shader_tgsm_raw tgsm_raw
#define WINED3D_SM4_ADDRESSING_SHIFT1
Definition: shader_sm4.c:83
const struct wined3d_shader_dst_param * dst
static BOOL shader_sm4_is_end(void *data, const DWORD **ptr)
Definition: shader_sm4.c:1742
#define WARN(fmt,...)
Definition: debug.h:111
#define U(x)
Definition: wordpad.c:44
static const struct wined3d_sm4_opcode_info opcode_table[]
Definition: shader_sm4.c:883
#define WINED3D_SM4_INSTRUCTION_FLAGS_MASK
Definition: shader_sm4.c:41
const DWORD * end
Definition: shader_sm4.c:446
#define WINED3D_SM4_INSTRUCTION_LENGTH_MASK
Definition: shader_sm4.c:38
GLdouble GLdouble t
Definition: gl.h:2047
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_shader_src_modifier *modifier)
Definition: shader_sm4.c:1377
struct wined3d_shader_index_range index_range
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define MAX_REG_OUTPUT
#define WINED3D_SM4_GS
static void shader_sm4_read_shader_data(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:529
GLuint GLuint end
Definition: gl.h:1545
wined3d_shader_register_type
static enum wined3d_primitive_type input_primitive_type_table[]
Definition: shader_sm4.c:478
#define WINED3D_SM5_CONTROL_POINT_COUNT_SHIFT
Definition: shader_sm4.c:64
static void shader_sm4_free(void *data)
Definition: shader_sm4.c:1306
union wined3d_shader_instruction::@270 declaration
#define WINED3D_SM4_AOFFIMMI_W_SHIFT
Definition: shader_sm4.c:34
#define WINED3D_SM4_SWIZZLE_SHIFT
Definition: shader_sm4.c:104
wined3d_shader_dst_modifier
const GLfloat * m
Definition: glext.h:10848
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
void(* read_opcode_func)(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:463
#define WINED3D_SM4_INSTRUCTION_FLAG_SATURATE
Definition: shader_sm4.c:113
#define WINED3D_SM5_HS
#define WINED3D_SM4_SHADER_DATA_TYPE_MASK
Definition: shader_sm4.c:56
#define WINED3D_SM4_SAMPLER_MODE_SHIFT
Definition: shader_sm4.c:52
__WINE_SERVER_LIST_INLINE struct list * list_head(const struct list *list)
Definition: list.h:131
static void shader_sm4_read_dcl_input_ps_siv(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:699
struct wined3d_shader_immediate_constant_buffer icb
Definition: shader_sm4.c:454
#define WINED3D_SM5_FP_ARRAY_SIZE_SHIFT
Definition: shader_sm4.c:67
Definition: shader_sm4.c:437
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
Definition: list.h:102
wined3d_sm4_output_primitive_type
Definition: shader_sm4.c:341
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)
Definition: shader_sm4.c:682
static void shader_sm5_read_dcl_resource_structured(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:849
wined3d_sm4_register_type
Definition: shader_sm4.c:304
static void shader_sm4_read_dcl_output_topology(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:627
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
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)
Definition: shader_sm4.c:827
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)
Definition: shader_sm4.c:618
struct wined3d_shader_semantic semantic
const struct wined3d_shader_src_param * src
enum wined3d_shader_src_modifier modifiers
#define WINED3D_SM4_REGISTER_MODIFIER
Definition: shader_sm4.c:81
static void shader_sm4_read_dcl_resource(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:558
unsigned int BOOL
Definition: ntddk_ex.h:94
static void shader_sm5_read_dcl_uav_structured(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:815
static void shader_sm4_read_dcl_sampler(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:608
static BOOL shader_sm4_read_reg_idx(struct wined3d_sm4_data *priv, const DWORD **ptr, const DWORD *end, DWORD addressing, struct wined3d_shader_register_index *reg_idx)
Definition: shader_sm4.c:1349
#define WINED3D_SM4_AOFFIMMI_U_MASK
Definition: shader_sm4.c:31
wined3d_sm4_resource_type
Definition: shader_sm4.c:402
#define e
Definition: ke_i.h:82
#define WINED3D_SM4_MODIFIER_AOFFIMMI
Definition: shader_sm4.c:29
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
static void shader_sm5_read_fcall(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:725
static void shader_sm5_read_control_point_count(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:759
static size_t elem
Definition: string.c:68
#define FIXME(fmt,...)
Definition: debug.h:110
static PVOID ptr
Definition: dispmode.c:27
static void shader_sm5_read_sync(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:867
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)
Definition: shader_sm4.c:1560
static const struct wined3d_sm4_opcode_info * get_opcode_info(enum wined3d_sm4_opcode opcode)
Definition: shader_sm4.c:1160
smooth NULL
Definition: ftsmooth.c:416
#define WINED3D_SM4_AOFFIMMI_U_SHIFT
Definition: shader_sm4.c:30
enum wined3d_tessellator_partitioning tessellator_partitioning
static void shader_sm5_read_dcl_thread_group(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:798
#define WINED3D_SM4_VERSION_MINOR(version)
Definition: shader_sm4.c:108
static enum wined3d_data_type data_type_table[]
Definition: shader_sm4.c:505
#define WINED3D_SM4_ADDRESSING_MASK1
Definition: shader_sm4.c:84
const struct wined3d_shader_frontend sm4_shader_frontend
Definition: shader_sm4.c:1748
wined3d_sm4_immconst_type
Definition: shader_sm4.c:396
enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx
#define TRACE_(x)
Definition: compat.h:66
#define WINED3D_SM5_UAV_FLAGS_MASK
Definition: shader_sm4.c:71
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
wined3d_shader_resource_type
#define WINED3DSP_NOSWIZZLE
const struct wined3d_shader_src_param * predicate
enum wined3d_sm4_opcode opcode
Definition: shader_sm4.c:459
#define WINED3D_SM4_OPCODE_MASK
Definition: shader_sm4.c:79
#define TRACE(s)
Definition: solgame.cpp:4
#define WINED3D_SM4_IMMCONST_TYPE_SHIFT
Definition: shader_sm4.c:98
static void shader_sm5_read_dcl_tessellator_output_primitive(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:783
static enum wined3d_data_type map_data_type(char t)
Definition: shader_sm4.c:1197
__WINE_SERVER_LIST_INLINE void list_move_head(struct list *dst, struct list *src)
Definition: list.h:176
static void shader_sm4_read_dcl_input_ps(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:691
#define WINED3D_SM5_CONTROL_POINT_COUNT_MASK
Definition: shader_sm4.c:65
if(!(yy_init))
Definition: macro.lex.yy.c:714
static void shader_sm5_read_dcl_resource_raw(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:860
static enum wined3d_primitive_type output_primitive_type_table[]
Definition: shader_sm4.c:468
static void shader_sm5_read_dcl_hs_max_tessfactor(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:791
static void shader_sm5_read_dcl_function_table(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:740
#define WINED3DSI_INDEXED_DYNAMIC
#define WINED3D_SM4_AOFFIMMI_V_SHIFT
Definition: shader_sm4.c:32
enum wined3d_tessellator_domain tessellator_domain
GLfloat param
Definition: glext.h:5796
#define WINED3D_SM5_DS
#define WINED3D_SM4_INTERPOLATION_MODE_SHIFT
Definition: shader_sm4.c:58
unsigned long DWORD
Definition: ntddk_ex.h:95
wined3d_shader_src_modifier
WINED3D_SHADER_INSTRUCTION_HANDLER
wined3d_sm4_shader_data_type
Definition: shader_sm4.c:431
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static void map_register(const struct wined3d_sm4_data *priv, struct wined3d_shader_register *reg)
Definition: shader_sm4.c:1172
#define WINED3D_SM4_AOFFIMMI_V_MASK
Definition: shader_sm4.c:33
#define WINED3D_SM4_RESOURCE_TYPE_SHIFT
Definition: shader_sm4.c:43
GLenum GLenum GLuint components
Definition: glext.h:9620
static void * shader_sm4_init(const DWORD *byte_code, size_t byte_code_size, const struct wined3d_shader_signature *output_signature)
Definition: shader_sm4.c:1221
#define WINED3D_SM4_SHADER_DATA_TYPE_SHIFT
Definition: shader_sm4.c:55
#define WINED3D_SM4_INSTRUCTION_FLAGS_SHIFT
Definition: shader_sm4.c:40
#define WINED3D_SM4_PS
#define WINED3D_SM4_SWIZZLE_TYPE_MASK
Definition: shader_sm4.c:96
uint32_t entry
Definition: isohybrid.c:63
struct wined3d_shader_version shader_version
Definition: shader_sm4.c:445
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define WINED3D_SM5_FP_TABLE_COUNT_MASK
Definition: shader_sm4.c:68
static void shader_sm4_read_declaration_dst(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:675
Definition: _list.h:228
GLenum src
Definition: glext.h:6340
#define WINED3D_SM4_ADDRESSING_RELATIVE
Definition: shader_sm4.c:110
#define WINED3D_SM4_AOFFIMMI_W_MASK
Definition: shader_sm4.c:35
struct wined3d_shader_indexable_temp indexable_temp
#define WINED3D_SM4_ADDRESSING_SHIFT0
Definition: shader_sm4.c:86
#define WINED3D_SM4_GLOBAL_FLAGS_SHIFT
Definition: shader_sm4.c:61
struct wined3d_shader_register reg
#define WINED3D_SM4_SAMPLER_MODE_MASK
Definition: shader_sm4.c:53
wined3d_primitive_type
Definition: wined3d.h:69
wined3d_sm4_opcode
Definition: shader_sm4.c:117
#define ERR(fmt,...)
Definition: debug.h:109
ULONG_PTR SIZE_T
Definition: typedefs.h:78
static enum wined3d_shader_register_type register_type_table[]
Definition: shader_sm4.c:1116
struct wined3d_shader_thread_group_size thread_group_size
struct list src
Definition: shader_sm4.c:453
#define WINED3D_SM5_UAV_FLAGS_SHIFT
Definition: shader_sm4.c:70
__WINE_SERVER_LIST_INLINE int list_empty(const struct list *list)
Definition: list.h:143
#define WINED3D_SM4_INTERPOLATION_MODE_MASK
Definition: shader_sm4.c:59
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
static enum wined3d_shader_resource_type resource_type_table[]
Definition: shader_sm4.c:490
const GLdouble * v
Definition: gl.h:2040
const struct wined3d_shader_src_param * rel_addr
#define WINED3D_SM4_SWIZZLE_TYPE_SHIFT
Definition: shader_sm4.c:95
WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader)
#define ARRAY_SIZE(a)
Definition: main.h:24
static void shader_sm4_read_dcl_indexable_temp(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:709
#define WINED3D_SM4_ADDRESSING_MASK0
Definition: shader_sm4.c:87
static struct wined3d_shader_src_param * get_src_param(struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:1319
wined3d_data_type
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)
Definition: shader_sm4.c:807
#define WINED3D_SM4_IMMCONST_TYPE_MASK
Definition: shader_sm4.c:99
static void shader_sm4_read_instruction_modifier(DWORD modifier, struct wined3d_shader_instruction *ins)
Definition: shader_sm4.c:1592
static int reg
Definition: i386-dis.c:1275
#define WINED3D_SM5_TESSELLATOR_SHIFT
Definition: shader_sm4.c:76
static void shader_sm4_read_instruction(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins)
Definition: shader_sm4.c:1623
static void shader_sm5_read_dcl_tessellator_domain(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:767
#define WINED3D_SM4_VERSION_MAJOR(version)
Definition: shader_sm4.c:107
WINE_DECLARE_DEBUG_CHANNEL(d3d_bytecode)
struct wined3d_shader_texel_offset texel_offset
struct wined3d_shader_register_semantic register_semantic
struct wined3d_shader_primitive_type primitive_type
const char * dst_info
Definition: shader_sm4.c:461
static void shader_sm4_read_dcl_constant_buffer(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:599
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
const DWORD * start
Definition: shader_sm4.c:446
enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx
Definition: shader_sm4.c:460
struct list entry
Definition: shader_sm4.c:439
#define WINED3D_SM4_VS
#define WINED3D_SM4_CONDITIONAL_NZ
Definition: shader_sm4.c:115
#define WINED3D_SM4_GLOBAL_FLAGS_MASK
Definition: shader_sm4.c:62
#define WINED3D_SM4_ADDRESSING_OFFSET
Definition: shader_sm4.c:111
struct wined3d_shader_tgsm_structured tgsm_structured
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)
Definition: shader_sm4.c:1509
GLfloat GLfloat p
Definition: glext.h:8902
struct list src_free
Definition: shader_sm4.c:452
#define LIST_ENTRY(type)
Definition: queue.h:175
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)
Definition: shader_sm4.c:520
#define WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT
Definition: shader_sm4.c:37
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE_ON(x)
Definition: compat.h:65
wined3d_sm4_data_type
Definition: shader_sm4.c:416
#define MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE
static void shader_sm4_read_dcl_input_primitive(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:643
#define WINED3D_SM4_WRITEMASK_SHIFT
Definition: shader_sm4.c:101
struct wined3d_shader_register reg
static void shader_sm5_read_dcl_function_body(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:733
static void shader_sm5_read_dcl_tessellator_partitioning(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:775
wined3d_sm4_swizzle_type
Definition: shader_sm4.c:389
#define WINED3D_SM5_SYNC_FLAGS_SHIFT
Definition: shader_sm4.c:73
const char * src_info
Definition: shader_sm4.c:462
struct wined3d_shader_function_table_pointer fp
wined3d_sm4_input_primitive_type
Definition: shader_sm4.c:348
static void shader_sm4_read_header(void *data, const DWORD **ptr, struct wined3d_shader_version *shader_version)
Definition: shader_sm4.c:1341
#define WINED3D_SM5_SYNC_FLAGS_MASK
Definition: shader_sm4.c:74
#define WINED3D_SM4_INDEX_TYPE_MASK
Definition: shader_sm4.c:50
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
#define WINED3D_SM4_REGISTER_TYPE_MASK
Definition: shader_sm4.c:93
struct wined3d_shader_structured_resource structured_resource
enum wined3d_tessellator_output_primitive tessellator_output_primitive
#define WINED3D_SM4_REGISTER_ORDER_MASK
Definition: shader_sm4.c:90
struct wined3d_shader_signature_element * elements
Definition: wined3d.h:2046
static void shader_sm5_read_dcl_tgsm_structured(struct wined3d_shader_instruction *ins, DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count, struct wined3d_sm4_data *priv)
Definition: shader_sm4.c:837