Example #1
0
        public void Update(DX11RenderContext context)
        {
            FMainBufferUpdate = FMainBuffer;
            if (this.FLayerInSpreadMax == 0)
            {
                return;
            }

            var newContext = !this.FTransformOutput[0].Contains(context);

            if (this.FInvalidate || newContext)
            {
                var bufferTypeChanged = this.currentBufferType != this.FBufferType[0];

                //refresh buffers?
                CheckBufferDispose <Matrix>(context, this.FTransformOutput[0], FTotalTransformCount, bufferTypeChanged);
                CheckBufferDispose <Color4>(context, this.FColorOutput[0], FTotalColorCount, bufferTypeChanged);

                CheckBufferDispose <Vector3>(context, this.FSpritesPositionOutput[0], FTotalSpritesPositionCount, bufferTypeChanged);
                CheckBufferDispose <Vector2>(context, this.FSpritesSizeOutput[0], FTotalSpritesSizeCount, bufferTypeChanged);
                CheckBufferDispose <Color4>(context, this.FSpritesColorOutput[0], FTotalSpritesColorCount, bufferTypeChanged);

                PrepareLocalGeometryBufferData(context);
                PrepareLocalSpriteBufferData(context);

                //make new buffers?
                CreateBuffer <Matrix>(FTransformOutput[0], context, FTotalTransformCount, FBufferTrans);
                CreateBuffer <Color4>(FColorOutput[0], context, FTotalColorCount, FBufferColor);

                CreateBuffer <Vector3>(FSpritesPositionOutput[0], context, FTotalSpritesPositionCount, FBufferSpritesPosition);
                CreateBuffer <Vector2>(FSpritesSizeOutput[0], context, FTotalSpritesSizeCount, FBufferSpritesSize);
                CreateBuffer <Color4>(FSpritesColorOutput[0], context, FTotalSpritesColorCount, FBufferSpritesColor);

                //if (FTotalTransformCount < 0 || FTotalColorCount < 0)
                //{
                //    this.FValid[0] = false;
                //}
            }

            this.FValid[0]         = true;
            this.currentBufferType = this.FBufferType[0];

            //write to buffers
            bool needContextCopy = this.FBufferType[0] != DX11BufferUploadType.Immutable;

            if (needContextCopy)
            {
                try
                {
                    WriteToBuffer(FTransformOutput[0], context, FBufferTrans, FTotalTransformCount);
                    WriteToBuffer(FColorOutput[0], context, FBufferColor, FTotalColorCount);

                    WriteToBuffer(FSpritesPositionOutput[0], context, FBufferSpritesPosition, FTotalSpritesPositionCount);
                    WriteToBuffer(FSpritesSizeOutput[0], context, FBufferSpritesSize, FTotalSpritesSizeCount);
                    WriteToBuffer(FSpritesColorOutput[0], context, FBufferSpritesColor, FTotalSpritesColorCount);
                }
                catch (Exception ex)
                {
                    this.pluginHost.Log(TLogType.Error, ex.Message);
                }
            }

            FInvalidate = false;
        }
Example #2
0
        public void Evaluate(int SpreadMax)
        {
            this.FInvalidate = false;

            //buffer outputs
            if (this.FApply[0] || this.FFirst)
            {
                if (this.FLayerIn.SliceCount > 0)
                {
                    this.FTransformOutput.SliceCount = 1;
                    this.FColorOutput.SliceCount     = 1;

                    this.FValid.SliceCount = 1;

                    //create geometry buffer resources
                    if (this.FTransformOutput[0] == null)
                    {
                        this.FTransformOutput[0] = new DX11Resource <IDX11ReadableStructureBuffer>();
                    }
                    if (this.FColorOutput[0] == null)
                    {
                        this.FColorOutput[0] = new DX11Resource <IDX11ReadableStructureBuffer>();
                    }

                    //creates sprites buffer resources
                    if (this.FSpritesPositionOutput[0] == null)
                    {
                        this.FSpritesPositionOutput[0] = new DX11Resource <IDX11ReadableStructureBuffer>();
                    }
                    if (this.FSpritesSizeOutput[0] == null)
                    {
                        this.FSpritesSizeOutput[0] = new DX11Resource <IDX11ReadableStructureBuffer>();
                    }
                    if (this.FSpritesColorOutput[0] == null)
                    {
                        this.FSpritesColorOutput[0] = new DX11Resource <IDX11ReadableStructureBuffer>();
                    }

                    //multiple layer input?
                    if (FLayerIn.SliceCount > 1)
                    {
                        FMainBuffer = DrawDescriptionLayer.Unite(FLayerIn);
                    }
                    else
                    {
                        FMainBuffer = FLayerIn[0];
                    }

                    //null connected?
                    if (FMainBuffer == null)
                    {
                        FMainBuffer = DrawDescriptionLayer.Default;
                    }
                }
                else
                {
                    if (this.FTransformOutput.SliceCount > 0 && this.FTransformOutput[0] != null)
                    {
                        this.FTransformOutput[0].Dispose();
                    }
                    this.FTransformOutput.SliceCount = 0;

                    if (this.FColorOutput.SliceCount > 0 && this.FColorOutput[0] != null)
                    {
                        this.FColorOutput[0].Dispose();
                    }
                    this.FColorOutput.SliceCount = 0;

                    this.FInstanceCounts.SliceCount  = 0;
                    this.FTexturePath.SliceCount     = 0;
                    this.FTransformCounts.SliceCount = 0;
                    this.FColorCounts.SliceCount     = 0;

                    this.FValid.SliceCount = 0;
                }

                this.FLayerInSpreadMax = this.FLayerIn.SliceCount;
                this.FInvalidate       = true;
                this.FFirst            = false;

                //mark buffers changed
                this.FTransformOutput.Stream.IsChanged = true;
                this.FColorOutput.Stream.IsChanged     = true;

                this.FSpritesPositionOutput.Stream.IsChanged = true;
                this.FSpritesSizeOutput.Stream.IsChanged     = true;
                this.FSpritesColorOutput.Stream.IsChanged    = true;

                //set all normal output pins and get the total counts
                UpdateNormalPins();
            }
        }
Example #3
0
        public void Evaluate(int SpreadMax)
        {
            //buffer outputs
            if (this.FApply[0] || this.FFirst)
            {
                if (this.FLayerIn.SliceCount > 0)
                {
                    this.FTransformOutput.SliceCount = 1;
                    this.FColorOutput.SliceCount     = 1;

                    this.FSpritesPositionOutput.SliceCount = 1;
                    this.FSpritesSizeOutput.SliceCount     = 1;
                    this.FSpritesColorOutput.SliceCount    = 1;

                    this.FValid.SliceCount = 1;

                    //create geometry buffer resources
                    if (this.FTransformOutput[0] == null)
                    {
                        this.FTransformOutput[0] = new DX11Resource <IDX11ReadableStructureBuffer>();
                    }
                    if (this.FColorOutput[0] == null)
                    {
                        this.FColorOutput[0] = new DX11Resource <IDX11ReadableStructureBuffer>();
                    }

                    //creates sprites buffer resources
                    if (this.FSpritesPositionOutput[0] == null)
                    {
                        this.FSpritesPositionOutput[0] = new DX11Resource <IDX11ReadableStructureBuffer>();
                    }
                    if (this.FSpritesSizeOutput[0] == null)
                    {
                        this.FSpritesSizeOutput[0] = new DX11Resource <IDX11ReadableStructureBuffer>();
                    }
                    if (this.FSpritesColorOutput[0] == null)
                    {
                        this.FSpritesColorOutput[0] = new DX11Resource <IDX11ReadableStructureBuffer>();
                    }

                    //multiple layer input?
                    if (FLayerIn.SliceCount > 1)
                    {
                        FMainBuffer = DrawDescriptionLayer.Unite(FLayerIn);
                    }
                    else
                    {
                        FMainBuffer = FLayerIn[0];
                    }

                    //null connected?
                    if (FMainBuffer == null)
                    {
                        FMainBuffer = DrawDescriptionLayer.Default;
                    }
                }
                else //no output
                {
                    //geos
                    this.FBlendIndex.SliceCount = 0;
                    this.FGeometryOutput.SafeDisposeAll();
                    this.FGeometryOutput.SliceCount = 0;

                    this.FTransformOutput.SafeDisposeAll();
                    this.FTransformOutput.SliceCount = 0;

                    this.FColorOutput.SafeDisposeAll();
                    this.FColorOutput.SliceCount = 0;

                    this.FInstanceCounts.SliceCount  = 0;
                    this.FTransformation.SliceCount  = 0;
                    this.FTexturePath.SliceCount     = 0;
                    this.FColor.SliceCount           = 0;
                    this.FMaterialIndex.SliceCount   = 0;
                    this.FSpaceIndex.SliceCount      = 0;
                    this.FClipRect.SliceCount        = 0;
                    this.FTransformCounts.SliceCount = 0;
                    this.FColorCounts.SliceCount     = 0;

                    //sprites
                    this.FSpritesBlendIndex.SliceCount = 0;
                    this.FSpritesPositionOutput.SafeDisposeAll();
                    this.FSpritesPositionOutput.SliceCount = 0;

                    this.FSpritesSizeOutput.SafeDisposeAll();
                    this.FSpritesSizeOutput.SliceCount = 0;

                    this.FSpritesColorOutput.SafeDisposeAll();
                    this.FSpritesColorOutput.SliceCount = 0;

                    this.FSpritesTransformations.SliceCount = 0;
                    this.FSpritesPositionCounts.SliceCount  = 0;
                    this.FSpritesSizeCounts.SliceCount      = 0;
                    this.FSpritesColorCounts.SliceCount     = 0;
                    this.FSpritesClipRect.SliceCount        = 0;
                    this.FSpritesTexturePath.SliceCount     = 0;
                    this.FSpritesSpaceIndex.SliceCount      = 0;

                    //text
                    this.FTextBlendIndex.SliceCount      = 0;
                    this.FTextSpaceIndex.SliceCount      = 0;
                    this.FTextTransformations.SliceCount = 0;
                    this.FTextColors.SliceCount          = 0;
                    this.FTextSizes.SliceCount           = 0;
                    this.FTexts.SliceCount                    = 0;
                    this.FTextFontNames.SliceCount            = 0;
                    this.FTextFontWeights.SliceCount          = 0;
                    this.FTextFontStyles.SliceCount           = 0;
                    this.FTextAlignmentsHorizontal.SliceCount = 0;
                    this.FTextAlignmentsVertical.SliceCount   = 0;
                    this.FTextWidths.SliceCount               = 0;

                    this.FValid.SliceCount = 0;
                }

                this.FLayerInSpreadMax = this.FLayerIn.SliceCount;
                this.FInvalidate       = true;
                this.FFirst            = false;

                //mark buffers changed
                this.FTransformOutput.Stream.IsChanged = true;
                this.FColorOutput.Stream.IsChanged     = true;

                this.FSpritesPositionOutput.Stream.IsChanged = true;
                this.FSpritesSizeOutput.Stream.IsChanged     = true;
                this.FSpritesColorOutput.Stream.IsChanged    = true;

                //set all normal output pins and get the total counts
                UpdateNormalPins();
            }
        }