コード例 #1
0
    private readonly Buffer refinedVertexBuffer;     // stream-out | vertex

    public VertexRefiner(Device device, ShaderCache shaderCache, SubdivisionMesh mesh, TexturedVertexInfo[] texturedVertexInfos)
    {
        this.refinedVertexCount = texturedVertexInfos.Length;

        var vertexRefinerShaderAndBytecode = shaderCache.GetVertexShader <FigureRenderer>("figure/rendering/VertexRefiner");

        this.vertexRefinerShader         = vertexRefinerShaderAndBytecode;
        this.vertexRefinerGeometryShader = new GeometryShader(device, vertexRefinerShaderAndBytecode.Bytecode, StreamOutputElements, new int[] { StreamStride }, GeometryShader.StreamOutputNoRasterizedStream);

        this.shaderResources = new ShaderResourceView[] {
            BufferUtilities.ToStructuredBufferView(device, mesh.Stencils.Segments),
            BufferUtilities.ToStructuredBufferView(device, mesh.Stencils.Elems),
            BufferUtilities.ToStructuredBufferView(device, texturedVertexInfos)
        };

        this.refinedVertexBuffer = new Buffer(device, new BufferDescription {
            SizeInBytes = refinedVertexCount * StreamStride,
            Usage       = ResourceUsage.Default,
            BindFlags   = BindFlags.StreamOutput | BindFlags.VertexBuffer
        });
    }
コード例 #2
0
        public static LegacyGameStats Parse(byte[] data, string game)
        {
            if (!GameStatTypeMappings.ContainsKey(game))
            {
                throw new InvalidOperationException($"The statistics format \"{game}\" is not supported.");
            }

            // Reflection to instantiate with the type of gamestats here
            var type         = GameStatTypeMappings[game];
            var stats        = new LegacyGameStats();
            var statsGeneric = typeof(LegacyGameStats).GetMethod(nameof(ParseFromBuffer))?.MakeGenericMethod(type);

            if (statsGeneric == null)
            {
                return(null);
            }

            // Invoke the read and return our stats
            using (var reader = BufferUtilities.CreateReader(data))
                statsGeneric.Invoke(stats, new object[] { reader });
            return(stats);
        }
コード例 #3
0
    public FigureRenderer(
        Device device, ShaderCache shaderCache, Scatterer scatterer, VertexRefiner vertexRefiner, MaterialSet materialSet, FigureSurface[] surfaces,
        bool isOneSided, int[] surfaceOrder, bool[] areUnorderedTranparent, TexturedVertexInfo[] texturedVertexInfos)
    {
        this.device        = device;
        this.scatterer     = scatterer;
        this.vertexRefiner = vertexRefiner;
        this.materialSet   = materialSet;
        this.surfaces      = surfaces;

        this.isOneSided              = isOneSided;
        this.surfaceOrder            = surfaceOrder;
        this.areUnorderedTransparent = areUnorderedTranparent;

        var vertexShaderAndBytecode = shaderCache.GetVertexShader <FigureRenderer>("figure/rendering/Figure");

        this.vertexShader      = vertexShaderAndBytecode;
        this.inputLayout       = new InputLayout(device, vertexShaderAndBytecode.Bytecode, vertexRefiner.RefinedVertexBufferInputElements);
        falseDepthVertexShader = shaderCache.GetVertexShader <FigureRenderer>("figure/rendering/Figure-FalseDepth");

        primaryTexturedVertexInfos  = texturedVertexInfos;
        texturedVertexInfoPairsView = BufferUtilities.ToStructuredBufferView(device, TexturedVertexInfoPair.Interleave(primaryTexturedVertexInfos, null));
    }
コード例 #4
0
 public override ReadOnlySequence <T> CreateWithContent(T[] data)
 {
     return(BufferUtilities.CreateBuffer <T>(data));
 }
コード例 #5
0
 public override ReadOnlySequence <T> CreateOfSize(int size)
 {
     return(BufferUtilities.CreateBuffer <T>(size));
 }
コード例 #6
0
 public void Setup()
 {
     _readOnlyBuffer = BufferUtilities.CreateBuffer(Enumerable.Range(100, 200).ToArray());
 }