|
| 1 | +// Unity C# reference source |
| 2 | +// Copyright (c) Unity Technologies. For terms of use, see |
| 3 | +// https://unity3d.com/legal/licenses/Unity_Reference_Only_License |
| 4 | + |
| 5 | +using System; |
| 6 | +using UnityEngine.Rendering; |
| 7 | +using UnityEngine.Scripting; |
| 8 | +using System.Runtime.InteropServices; |
| 9 | + |
| 10 | +namespace UnityEditor.Rendering |
| 11 | +{ |
| 12 | + [StructLayout(LayoutKind.Sequential)] |
| 13 | + [UsedByNativeCode] |
| 14 | + public struct ShaderSnippetData |
| 15 | + { |
| 16 | + private ShaderType m_ShaderType; |
| 17 | + private PassType m_PassType; |
| 18 | + private string m_PassName; |
| 19 | + |
| 20 | + public ShaderType shaderType |
| 21 | + { |
| 22 | + get { return m_ShaderType; } |
| 23 | + } |
| 24 | + |
| 25 | + public PassType passType |
| 26 | + { |
| 27 | + get { return m_PassType; } |
| 28 | + } |
| 29 | + |
| 30 | + public string passName |
| 31 | + { |
| 32 | + get { return m_PassName; } |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + [StructLayout(LayoutKind.Sequential)] |
| 37 | + [UsedByNativeCode] |
| 38 | + public struct ShaderCompilerData |
| 39 | + { |
| 40 | + public ShaderKeywordSet shaderKeywordSet; |
| 41 | + public PlatformKeywordSet platformKeywordSet; // C++ side is PlatformCapKeywords |
| 42 | + private ShaderRequirements m_ShaderRequirements; |
| 43 | + private GraphicsTier m_GraphicsTier; |
| 44 | + private ShaderCompilerPlatform m_ShaderCompilerPlatform; |
| 45 | + |
| 46 | + public ShaderRequirements shaderRequirements |
| 47 | + { |
| 48 | + get { return m_ShaderRequirements; } |
| 49 | + } |
| 50 | + |
| 51 | + public GraphicsTier graphicsTier |
| 52 | + { |
| 53 | + get { return m_GraphicsTier; } |
| 54 | + } |
| 55 | + |
| 56 | + public ShaderCompilerPlatform shaderCompilerPlatform |
| 57 | + { |
| 58 | + get { return m_ShaderCompilerPlatform; } |
| 59 | + } |
| 60 | + } |
| 61 | + |
| 62 | + public enum ShaderCompilerPlatform |
| 63 | + { |
| 64 | + None = 0, // For non initialized variable. |
| 65 | + D3D = 4, // Direct3D 11 (FL10.0 and up) and Direct3D 12, compiled with MS D3DCompiler |
| 66 | + GLES20 = 5, // OpenGL ES 2.0 / WebGL 1.0, compiled with hlsl2glslfork + glsl-optimizer |
| 67 | + GLES3x = 9, // OpenGL ES 3.0+ / WebGL 2.0, compiled with MS D3DCompiler + HLSLcc |
| 68 | + Vita = 10, // Sony PSP2/Vita |
| 69 | + PS4 = 11, // Sony PS4 |
| 70 | + XboxOneD3D11 = 12, // MS XboxOne |
| 71 | + Metal = 14, // Apple Metal, compiled with MS D3DCompiler + HLSLcc |
| 72 | + OpenGLCore = 15, // Desktop OpenGL 3+, compiled with MS D3DCompiler + HLSLcc |
| 73 | + N3DS = 16, // Nintendo 3DS |
| 74 | + Vulkan = 18, // Vulkan SPIR-V, compiled with MS D3DCompiler + HLSLcc |
| 75 | + Switch = 19, // Nintendo Switch (NVN) |
| 76 | + XboxOneD3D12 = 20 // Xbox One D3D12 |
| 77 | + } |
| 78 | + |
| 79 | + [Flags] |
| 80 | + public enum ShaderRequirements |
| 81 | + { |
| 82 | + None = 0, |
| 83 | + BaseShaders = (1 << 0), // Basic "can have shaders" (SM2.0 level) capability |
| 84 | + Interpolators10 = (1 << 1), // 10 interpolators/varyings |
| 85 | + Interpolators32 = (1 << 2), // 32 interpolators/varyings |
| 86 | + MRT4 = (1 << 3), // Multiple render targets, at least 4 (ability for fragment shader to output up to 4 colors) |
| 87 | + MRT8 = (1 << 4), // Multiple render targets, at least 8 (ability for fragment shader to output up to 8 colors) |
| 88 | + Derivatives = (1 << 5), // Derivative (ddx/ddy) instructions in the fragment shader |
| 89 | + SampleLOD = (1 << 6), // Ability to sample textures in fragment shader with explicit LOD level |
| 90 | + FragCoord = (1 << 7), // Pixel position (VPOS/SV_Position/gl_FragCoord) input in fragment shader |
| 91 | + // = (1 << 8), // unused |
| 92 | + Interpolators15Integers = (1 << 9), // Integers + Interpolators15. We bundle them together since extremely unlikely a GPU/API will ever exist that only has part of that. |
| 93 | + Texture2DArray = (1 << 10), // 2DArray textures |
| 94 | + Instancing = (1 << 11), // SV_InstanceID shader input |
| 95 | + Geometry = (1 << 12), // Geometry shaders |
| 96 | + CubeArray = (1 << 13), // Cubemap arrays |
| 97 | + Compute = (1 << 14), // Compute shaders |
| 98 | + RandomWrite = (1 << 15), // Random-write textures (UAVs) from shader stages |
| 99 | + TessellationCompute = (1 << 16), // Tessellator hardware, i.e. Metal style |
| 100 | + TessellationShaders = (1 << 17), // Tessellation shaders, i.e. DX11 style (hull/domain shader stages) |
| 101 | + SparseTexelResident = (1 << 18), // Sparse textures with sampling instructions that return residency info |
| 102 | + FramebufferFetch = (1 << 19), // Framebuffer fetch (ability to have in+out fragment shader color params) |
| 103 | + MSAATextureSamples = (1 << 20) // Access to MSAA'd texture samples in shaders (e.g. HLSL Texture2DMS) |
| 104 | + } |
| 105 | + |
| 106 | + public enum ShaderType |
| 107 | + { |
| 108 | + Vertex = 1, |
| 109 | + Fragment = 2, |
| 110 | + Geometry = 3, |
| 111 | + Hull = 4, |
| 112 | + Domain = 5 |
| 113 | + } |
| 114 | +} |
0 commit comments