示例#1
0
文件: Utils.cs 项目: zeta1999/Vrmac
        public static void initState(iPipelineStateFactory stateFactory, iShaderFactory shaderFactory, iStorageFolder assets, IShader vs, string ps, string name)
        {
            stateFactory.clear();
            stateFactory.setName(name + " PSO");

            // VS input layout
            LayoutElement elt = new LayoutElement(false)
            {
                InputIndex    = 0,
                BufferSlot    = 0,
                NumComponents = 2,
                ValueType     = GpuValueType.Float32,
                IsNormalized  = false
            };

            stateFactory.graphicsLayoutElement(elt);

            // Shaders
            stateFactory.graphicsVertexShader(vs);
            using (var shader = shaderFactory.compileHlslFile(assets, ps, ShaderType.Pixel, name + " PS"))
                stateFactory.graphicsPixelShader(shader);

            // Mutable texture variable
            stateFactory.layoutVariable(ShaderType.Pixel, ShaderResourceVariableType.Mutable, "g_Texture");
            // Static sampler
            SamplerDesc samplerDesc = new SamplerDesc(false)
            {
                MinFilter = FilterType.Point,
                MagFilter = FilterType.Point,
                MipFilter = FilterType.Point,
            };

            stateFactory.layoutStaticSampler(ShaderType.Pixel, ref samplerDesc, "g_Texture");
        }
示例#2
0
        /// <summary>Construct the object and create the required GPU resources</summary>
        public CursorRenderer(Context context, IRenderDevice device)
        {
            this.context = context;
            vertexBuffer = createVertexBuffer(device);

            iShaderFactory shaderFactory = device.GetShaderFactory();
            iStorageFolder assets        = StorageFolder.embeddedResources(Assembly.GetExecutingAssembly(), resourceFolder);
            IShader        vs            = shaderFactory.compileHlslFile(assets, "CursorVS.hlsl", ShaderType.Vertex);

            using (iPipelineStateFactory stateFactory = device.CreatePipelineStateFactory())
            {
                staticCursor     = new StaticCursor(context, device, stateFactory, shaderFactory, assets, vs);
                animatedCursor   = new AnimatedCursor(context, device, stateFactory, shaderFactory, assets);
                monochromeCursor = new MonoCursor(context, device, stateFactory, shaderFactory, assets, vs);
            }

            cursorPosition.setWindowSize(context.swapChainSize);

            // Subscribe to the resized event
            context.swapChainResized.add(this, onSwapChainResized);
        }
示例#3
0
文件: Utils.cs 项目: zeta1999/Vrmac
 public static void initState(iPipelineStateFactory stateFactory, iShaderFactory shaderFactory, iStorageFolder assets, string vs, string ps, string name)
 {
     using (var shader = shaderFactory.compileHlslFile(assets, vs, ShaderType.Vertex, name + " VS"))
         initState(stateFactory, shaderFactory, assets, shader, ps, name);
 }