internal static CullFaceMode VdToGLCullFaceMode(FaceCullMode cullMode) { switch (cullMode) { case FaceCullMode.Back: return(CullFaceMode.Back); case FaceCullMode.Front: return(CullFaceMode.Front); default: throw Illegal.Value <FaceCullMode>(); } }
internal static MTLTriangleFillMode VdToMTLFillMode(PolygonFillMode fillMode) { switch (fillMode) { case PolygonFillMode.Solid: return(MTLTriangleFillMode.Fill); case PolygonFillMode.Wireframe: return(MTLTriangleFillMode.Lines); default: throw Illegal.Value <PolygonFillMode>(); } }
internal static DrawElementsType VdToGLDrawElementsType(IndexFormat format) { switch (format) { case IndexFormat.UInt16: return(DrawElementsType.UnsignedShort); case IndexFormat.UInt32: return(DrawElementsType.UnsignedInt); default: throw Illegal.Value <IndexFormat>(); } }
internal static FillMode VdToD3D11FillMode(PolygonFillMode fillMode) { switch (fillMode) { case PolygonFillMode.Solid: return(FillMode.Solid); case PolygonFillMode.Wireframe: return(FillMode.Wireframe); default: throw Illegal.Value <PolygonFillMode>(); } }
internal static Format ToDxgiFormat(IndexFormat format) { switch (format) { case IndexFormat.UInt16: return(Format.R16_UInt); case IndexFormat.UInt32: return(Format.R32_UInt); default: throw Illegal.Value <IndexFormat>(); } }
internal static Format ToDxgiFormat(PixelFormat format, bool depthFormat) { switch (format) { case PixelFormat.R8_G8_B8_A8_UNorm: return(Format.R8G8B8A8_UNorm); case PixelFormat.B8_G8_R8_A8_UNorm: return(Format.B8G8R8A8_UNorm); case PixelFormat.R8_UNorm: return(Format.R8_UNorm); case PixelFormat.R8_G8_SNorm: return(Format.R8G8_SNorm); case PixelFormat.R16_UNorm: return(depthFormat ? Format.R16_Typeless : Format.R16_UNorm); case PixelFormat.R32_G32_B32_A32_Float: return(Format.R32G32B32A32_Float); case PixelFormat.R32_G32_B32_A32_UInt: return(Format.R32G32B32A32_UInt); case PixelFormat.R32_Float: return(depthFormat ? Format.R32_Typeless : Format.R32_Float); case PixelFormat.BC1_Rgb_UNorm: case PixelFormat.BC1_Rgba_UNorm: return(Format.BC1_UNorm); case PixelFormat.BC2_UNorm: return(Format.BC2_UNorm); case PixelFormat.BC3_UNorm: return(Format.BC3_UNorm); case PixelFormat.D24_UNorm_S8_UInt: Debug.Assert(depthFormat); return(Format.R24G8_Typeless); case PixelFormat.D32_Float_S8_UInt: Debug.Assert(depthFormat); return(Format.R32G8X24_Typeless); default: throw Illegal.Value <PixelFormat>(); } }
internal static FrontFaceDirection VdToGLFrontFaceDirection(FrontFace frontFace) { switch (frontFace) { case FrontFace.Clockwise: return(FrontFaceDirection.Cw); case FrontFace.CounterClockwise: return(FrontFaceDirection.Ccw); default: throw Illegal.Value <FrontFace>(); } }
internal static VkPolygonMode VdToVkPolygonMode(PolygonFillMode fillMode) { switch (fillMode) { case PolygonFillMode.Solid: return(VkPolygonMode.Fill); case PolygonFillMode.Wireframe: return(VkPolygonMode.Line); default: throw Illegal.Value <PolygonFillMode>(); } }
public static InputClassification ConvertInputClass(VertexElementInputClass inputClass) { switch (inputClass) { case VertexElementInputClass.PerVertex: return(InputClassification.PerVertexData); case VertexElementInputClass.PerInstance: return(InputClassification.PerInstanceData); default: throw Illegal.Value <VertexElementInputClass>(); } }
internal static VkIndexType VdToVkIndexFormat(IndexFormat format) { switch (format) { case IndexFormat.UInt16: return(VkIndexType.Uint16); case IndexFormat.UInt32: return(VkIndexType.Uint32); default: throw Illegal.Value <IndexFormat>(); } }
internal static FillMode ConvertFillMode(TriangleFillMode fillMode) { switch (fillMode) { case TriangleFillMode.Solid: return(FillMode.Solid); case TriangleFillMode.Wireframe: return(FillMode.Wireframe); default: throw Illegal.Value <TriangleFillMode>(); } }
internal static void VdToGLTextureMinMagFilter(SamplerFilter filter, bool mip, out TextureMinFilter min, out TextureMagFilter mag) { switch (filter) { case SamplerFilter.Anisotropic: case SamplerFilter.MinPoint_MagPoint_MipPoint: min = mip ? TextureMinFilter.NearestMipmapNearest : TextureMinFilter.Nearest; mag = TextureMagFilter.Nearest; break; case SamplerFilter.MinPoint_MagPoint_MipLinear: min = mip ? TextureMinFilter.NearestMipmapLinear : TextureMinFilter.Nearest; mag = TextureMagFilter.Nearest; break; case SamplerFilter.MinPoint_MagLinear_MipPoint: min = mip ? TextureMinFilter.NearestMipmapNearest : TextureMinFilter.Nearest; mag = TextureMagFilter.Linear; break; case SamplerFilter.MinPoint_MagLinear_MipLinear: min = mip ? TextureMinFilter.NearestMipmapLinear : TextureMinFilter.Nearest; mag = TextureMagFilter.Linear; break; case SamplerFilter.MinLinear_MagPoint_MipPoint: min = mip ? TextureMinFilter.LinearMipmapNearest : TextureMinFilter.Linear; mag = TextureMagFilter.Nearest; break; case SamplerFilter.MinLinear_MagPoint_MipLinear: min = mip ? TextureMinFilter.LinearMipmapLinear : TextureMinFilter.Linear; mag = TextureMagFilter.Nearest; break; case SamplerFilter.MinLinear_MagLinear_MipPoint: min = mip ? TextureMinFilter.LinearMipmapNearest : TextureMinFilter.Linear; mag = TextureMagFilter.Linear; break; case SamplerFilter.MinLinear_MagLinear_MipLinear: min = mip ? TextureMinFilter.LinearMipmapLinear : TextureMinFilter.Linear; mag = TextureMagFilter.Linear; break; default: throw Illegal.Value <SamplerFilter>(); } }
public MTLResourceLayout(ref ResourceLayoutDescription description, MTLGraphicsDevice gd) : base(ref description) { ResourceLayoutElementDescription[] elements = description.Elements; _bindingInfosByVdIndex = new ResourceBindingInfo[elements.Length]; uint bufferIndex = 0; uint texIndex = 0; uint samplerIndex = 0; for (int i = 0; i < _bindingInfosByVdIndex.Length; i++) { uint slot; switch (elements[i].Kind) { case ResourceKind.UniformBuffer: slot = bufferIndex++; break; case ResourceKind.StructuredBufferReadOnly: slot = bufferIndex++; break; case ResourceKind.StructuredBufferReadWrite: slot = bufferIndex++; break; case ResourceKind.TextureReadOnly: slot = texIndex++; break; case ResourceKind.TextureReadWrite: slot = texIndex++; break; case ResourceKind.Sampler: slot = samplerIndex++; break; default: throw Illegal.Value <ResourceKind>(); } _bindingInfosByVdIndex[i] = new ResourceBindingInfo(slot, elements[i].Stages, elements[i].Kind); } BufferCount = bufferIndex; TextureCount = texIndex; SamplerCount = samplerIndex; }
private byte[] CompileCode(ShaderDescription description) { string profile; switch (description.Stage) { case ShaderStages.Vertex: profile = "vs_5_0"; break; case ShaderStages.Geometry: profile = "gs_5_0"; break; case ShaderStages.TessellationControl: profile = "hs_5_0"; break; case ShaderStages.TessellationEvaluation: profile = "ds_5_0"; break; case ShaderStages.Fragment: profile = "ps_5_0"; break; case ShaderStages.Compute: profile = "cs_5_0"; break; default: throw Illegal.Value <ShaderStages>(); } ShaderFlags flags = description.Debug ? ShaderFlags.Debug : ShaderFlags.OptimizationLevel3; CompilationResult result = ShaderBytecode.Compile( description.ShaderBytes, description.EntryPoint, profile, flags); if (result.ResultCode.Failure || !string.IsNullOrEmpty(result.Message)) { throw new VeldridException($"Failed to compile HLSL code: {result.Message}"); } return(result.Bytecode.Data); }
internal static MTLPixelFormat VdToMTLPixelFormat(PixelFormat format, bool depthFormat) { switch (format) { case PixelFormat.B8_G8_R8_A8_UNorm: return(MTLPixelFormat.BGRA8Unorm); case PixelFormat.BC1_Rgb_UNorm: case PixelFormat.BC1_Rgba_UNorm: return(MTLPixelFormat.BC1_RGBA); case PixelFormat.BC2_UNorm: return(MTLPixelFormat.BC2_RGBA); case PixelFormat.BC3_UNorm: return(MTLPixelFormat.BC3_RGBA); case PixelFormat.D24_UNorm_S8_UInt: return(MTLPixelFormat.Depth24Unorm_Stencil8); case PixelFormat.D32_Float_S8_UInt: return(MTLPixelFormat.Depth32Float_Stencil8); case PixelFormat.R16_UNorm: return(depthFormat ? MTLPixelFormat.Depth16Unorm : MTLPixelFormat.R16Unorm); case PixelFormat.R32_Float: return(depthFormat ? MTLPixelFormat.Depth32Float : MTLPixelFormat.R32Float); case PixelFormat.R32_G32_B32_A32_Float: return(MTLPixelFormat.RGBA32Float); case PixelFormat.R32_G32_B32_A32_UInt: return(MTLPixelFormat.RGBA32Uint); case PixelFormat.R8_G8_B8_A8_UNorm: return(MTLPixelFormat.RGBA8Unorm); case PixelFormat.R8_UNorm: return(MTLPixelFormat.R8Unorm); case PixelFormat.R8_G8_SNorm: return(MTLPixelFormat.RG8Snorm); default: throw Illegal.Value <PixelFormat>(); } }
internal static CullFaceMode ConvertCullMode(FaceCullingMode cullMode) { switch (cullMode) { case FaceCullingMode.Back: return(CullFaceMode.Back); case FaceCullingMode.Front: return(CullFaceMode.Front); default: // FaceCullingMode.None should not be converted. // It translates to GL.Disable(EnableCap.CullFace). throw Illegal.Value <FaceCullingMode>(); } }
public static ShaderStages GLToVeldridShaderType(OpenTK.Graphics.ES30.ShaderType type) { switch (type) { case OpenTK.Graphics.ES30.ShaderType.FragmentShader: return(ShaderStages.Fragment); case OpenTK.Graphics.ES30.ShaderType.VertexShader: return(ShaderStages.Vertex); throw new NotSupportedException($"The shader type {type} is not supported."); default: throw Illegal.Value <OpenTK.Graphics.ES30.ShaderType>(); } }
protected void Btn_Solve_Click(object sender, EventArgs e) { Illegal illegal = new Illegal(); illegal.IllegalId = Convert.ToInt32(Request.QueryString["illegalId"]); illegal.IllegalSolve = this.illegalSolve.Text; illegal.IllegalScore = this.illegalScore.Text; if (illegal.UpdateSolvingIllegal()) { Response.Write("<script>alert('违规信息处理成功!');location.href='illegalInfoManage.aspx';</script>"); } else { Response.Write("<script>alert('" + illegal.ErrMessage + "');location.href='illegalInfoAudit.aspx?illegalId=" + Request.QueryString["illegalId"] + "';</script>"); } }
internal static VkSamplerAddressMode VdToVkSamplerAddressMode(SamplerAddressMode mode) { switch (mode) { case SamplerAddressMode.Wrap: return VkSamplerAddressMode.Repeat; case SamplerAddressMode.Mirror: return VkSamplerAddressMode.MirroredRepeat; case SamplerAddressMode.Clamp: return VkSamplerAddressMode.ClampToEdge; case SamplerAddressMode.Border: return VkSamplerAddressMode.ClampToBorder; default: throw Illegal.Value<SamplerAddressMode>(); } }
private byte[] CompileCode(ShaderDescription description) { string profile; switch (description.Stage) { case ShaderStages.Vertex: profile = "vs_5_0"; break; case ShaderStages.Geometry: profile = "gs_5_0"; break; case ShaderStages.TessellationControl: profile = "hs_5_0"; break; case ShaderStages.TessellationEvaluation: profile = "ds_5_0"; break; case ShaderStages.Fragment: profile = "ps_5_0"; break; case ShaderStages.Compute: profile = "cs_5_0"; break; default: throw Illegal.Value <ShaderStages>(); } ShaderFlags flags = description.Debug ? ShaderFlags.Debug : ShaderFlags.OptimizationLevel3; Compiler.Compile(description.ShaderBytes, description.EntryPoint, null, profile, out Blob result, out Blob error); if (result == null) { throw new VeldridException($"Failed to compile HLSL code: {Encoding.ASCII.GetString(error.GetBytes())}"); } return(result.GetBytes()); }
internal static SharpDX.Direct3D11.MapMode VdToD3D11MapMode(bool isDynamic, MapMode mode) { switch (mode) { case MapMode.Read: return(SharpDX.Direct3D11.MapMode.Read); case MapMode.Write: return(isDynamic ? SharpDX.Direct3D11.MapMode.WriteDiscard : SharpDX.Direct3D11.MapMode.Write); case MapMode.ReadWrite: return(SharpDX.Direct3D11.MapMode.ReadWrite); default: throw Illegal.Value <MapMode>(); } }
internal static BufferAccessMask VdToGLMapMode(MapMode mode) { switch (mode) { case MapMode.Read: return(BufferAccessMask.Read); case MapMode.Write: return(BufferAccessMask.Write | BufferAccessMask.InvalidateBuffer); case MapMode.ReadWrite: return(BufferAccessMask.Read | BufferAccessMask.Write); default: throw Illegal.Value <MapMode>(); } }
public static int GetIndexFormatElementByteSize(IndexFormat format) { switch (format) { case IndexFormat.UInt32: return(4); case IndexFormat.UInt16: return(2); case IndexFormat.UInt8: return(1); default: throw Illegal.Value <IndexFormat>(); } }
internal static GLPixelFormat VdToGLPixelFormat(PixelFormat format) { switch (format) { case PixelFormat.R8_G8_B8_A8_UNorm: return(GLPixelFormat.Rgba); case PixelFormat.B8_G8_R8_A8_UNorm: return(GLPixelFormat.Bgra); case PixelFormat.R8_UNorm: return(GLPixelFormat.Red); case PixelFormat.R8_G8_SNorm: return(GLPixelFormat.RgInteger); case PixelFormat.R16_UNorm: return(GLPixelFormat.Red); case PixelFormat.R32_G32_B32_A32_Float: return(GLPixelFormat.Rgba); case PixelFormat.R32_G32_B32_A32_UInt: return(GLPixelFormat.RgbaInteger); case PixelFormat.R32_Float: return(GLPixelFormat.Red); case PixelFormat.BC1_Rgb_UNorm: return(GLPixelFormat.Rgb); case PixelFormat.BC1_Rgba_UNorm: case PixelFormat.BC2_UNorm: case PixelFormat.BC3_UNorm: return(GLPixelFormat.Rgba); case PixelFormat.D24_UNorm_S8_UInt: return(GLPixelFormat.DepthStencil); case PixelFormat.D32_Float_S8_UInt: return(GLPixelFormat.DepthStencil); default: throw Illegal.Value <PixelFormat>(); } }
internal static MTLSamplerBorderColor VdToMTLBorderColor(SamplerBorderColor borderColor) { switch (borderColor) { case SamplerBorderColor.TransparentBlack: return(MTLSamplerBorderColor.TransparentBlack); case SamplerBorderColor.OpaqueBlack: return(MTLSamplerBorderColor.OpaqueBlack); case SamplerBorderColor.OpaqueWhite: return(MTLSamplerBorderColor.OpaqueWhite); default: throw Illegal.Value <SamplerBorderColor>(); } }
public override Shader CreateShader(ShaderType type, string shaderCode, string name) { switch (type) { case ShaderType.Vertex: return(new D3DVertexShader(_device, shaderCode, name)); case ShaderType.Geometry: return(new D3DGeometryShader(_device, shaderCode, name)); case ShaderType.Fragment: return(new D3DFragmentShader(_device, shaderCode, name)); default: throw Illegal.Value <ShaderType>(); } }
internal static CullMode VeldridToD3DFaceCullingMode(FaceCullingMode cullMode) { switch (cullMode) { case FaceCullingMode.Back: return(CullMode.Back); case FaceCullingMode.Front: return(CullMode.Front); case FaceCullingMode.None: return(CullMode.None); default: throw Illegal.Value <FaceCullingMode>(); } }
public D3D11Shader(Device device, ShaderDescription description) : base(description.Stage) { if (description.ShaderBytes.Length > 4 && description.ShaderBytes[0] == 0x44 && description.ShaderBytes[1] == 0x58 && description.ShaderBytes[2] == 0x42 && description.ShaderBytes[3] == 0x43) { Bytecode = Util.ShallowClone(description.ShaderBytes); } else { Bytecode = CompileCode(description); } switch (description.Stage) { case ShaderStages.Vertex: DeviceShader = new VertexShader(device, Bytecode); break; case ShaderStages.Geometry: DeviceShader = new GeometryShader(device, Bytecode); break; case ShaderStages.TessellationControl: DeviceShader = new HullShader(device, Bytecode); break; case ShaderStages.TessellationEvaluation: DeviceShader = new DomainShader(device, Bytecode); break; case ShaderStages.Fragment: DeviceShader = new PixelShader(device, Bytecode); break; case ShaderStages.Compute: DeviceShader = new ComputeShader(device, Bytecode); break; default: throw Illegal.Value <ShaderStages>(); } }
internal static VkImageType VdToVkTextureType(TextureType type) { switch (type) { case TextureType.Texture1D: return(VkImageType.Image1D); case TextureType.Texture2D: return(VkImageType.Image2D); case TextureType.Texture3D: return(VkImageType.Image3D); default: throw Illegal.Value <TextureType>(); } }
internal static VkCullModeFlags VdToVkCullMode(FaceCullMode cullMode) { switch (cullMode) { case FaceCullMode.Back: return(VkCullModeFlags.Back); case FaceCullMode.Front: return(VkCullModeFlags.Front); case FaceCullMode.None: return(VkCullModeFlags.None); default: throw Illegal.Value <FaceCullMode>(); } }