| 1876 | } |
| 1877 | |
| 1878 | const char* MSLGenerator::TranslateInputSemantic(const char* semantic) |
| 1879 | { |
| 1880 | if (semantic == NULL) |
| 1881 | return NULL; |
| 1882 | |
| 1883 | uint32_t length, index; |
| 1884 | ParseSemantic(semantic, &length, &index); |
| 1885 | |
| 1886 | if (m_target == HLSLTarget_VertexShader) { |
| 1887 | // These are DX10 convention |
| 1888 | if (String_Equal(semantic, "SV_InstanceID")) |
| 1889 | return "instance_id"; |
| 1890 | if (String_Equal(semantic, "SV_VertexID")) |
| 1891 | return "vertex_id"; |
| 1892 | |
| 1893 | // requires SPV_KHR_shader_draw_parameters for Vulkan |
| 1894 | // not a DX12 construct. |
| 1895 | if (String_Equal(semantic, "BASEVERTEX")) |
| 1896 | return "base_vertex"; |
| 1897 | if (String_Equal(semantic, "BASEINSTANCE")) |
| 1898 | return "base_instance"; |
| 1899 | //if (String_Equal(semantic, "DRAW_INDEX")) |
| 1900 | // return "draw_index"; |
| 1901 | |
| 1902 | // TODO: primitive_id, barycentric |
| 1903 | |
| 1904 | // Handle attributes |
| 1905 | |
| 1906 | // Can set custom attributes via a callback |
| 1907 | if (m_options.attributeCallback) { |
| 1908 | char name[64]; |
| 1909 | ASSERT(length < sizeof(name)); |
| 1910 | |
| 1911 | strncpy(name, semantic, length); |
| 1912 | name[length] = 0; |
| 1913 | |
| 1914 | int attribute = m_options.attributeCallback(name, index); |
| 1915 | |
| 1916 | if (attribute >= 0) { |
| 1917 | return m_tree->AddStringFormat("attribute(%d)", attribute); |
| 1918 | } |
| 1919 | } |
| 1920 | |
| 1921 | if (String_Equal(semantic, "SV_Position")) |
| 1922 | return "attribute(POSITION)"; |
| 1923 | |
| 1924 | return m_tree->AddStringFormat("attribute(%s)", semantic); |
| 1925 | } |
| 1926 | else if (m_target == HLSLTarget_PixelShader) { |
| 1927 | // PS inputs |
| 1928 | |
| 1929 | if (String_Equal(semantic, "SV_Position")) |
| 1930 | return "position"; |
| 1931 | |
| 1932 | // if (String_Equal(semantic, "POSITION")) |
| 1933 | // return "position"; |
| 1934 | if (String_Equal(semantic, "SV_IsFrontFace")) |
| 1935 | return "front_facing"; |
nothing calls this directly
no test coverage detected