Example #1
0
        public unsafe void Decode(IContext context, ManualMipChain target, ManualMipChain temporalDiff, ManualMipChain previous, int mostDetailedMip)
        {
            var pipeline = context.Pipeline;
            fullTextureProcessor.PrepareContext(context);
            pipeline.Viewports[0].Set(target.Width, target.Height);
            framebuffer.AttachTextureImage(FramebufferAttachmentPoint.Color0, target[0], 0);
            pipeline.Framebuffer = framebuffer;

            Vector4 mipInfoData;
            var mipInfoPtr = (int*)&mipInfoData;
            mipInfoPtr[0] = mostDetailedMip;
            mipInfoPtr[1] = 1 << mostDetailedMip;
            mipInfoBuffer.SetDataByMapping(pclWorkarounds, (IntPtr)mipInfoPtr);

            pipeline.UniformBuffers[0] = mipInfoBuffer;
            pipeline.Textures[0] = temporalDiff[mostDetailedMip];
            pipeline.Samplers[0] = sampler;
            pipeline.Textures[1] = previous[0];
            pipeline.Samplers[1] = sampler;
            pipeline.Textures[2] = previous[mostDetailedMip];
            pipeline.Samplers[2] = sampler;

            context.DrawElements(BeginMode.Triangles, 6, DrawElementsType.UnsignedShort, 0);
            framebuffer.DetachColorStartingFrom(0);
        }
Example #2
0
        public unsafe void GenerateMips(IContext context, ManualMipChain target)
        {
            var pipeline = context.Pipeline;
            fullTextureProcessor.PrepareContext(context);
            pipeline.Framebuffer = framebuffer;
            pipeline.Samplers[0] = sampler;
            pipeline.UniformBuffers[0] = mipInfoBuffer;

            for (int i = 1; i < EncodingConstants.MipLevels; i++)
            {
                pipeline.Viewports[0].Set(target.Width >> i, target.Height >> i);

                Vector4 mipInfoData;
                var mipInfoPtr = (int*)&mipInfoData;
                mipInfoPtr[0] = i;
                mipInfoBuffer.SetDataByMapping(pclWorkarounds, (IntPtr)mipInfoPtr);

                framebuffer.AttachTextureImage(FramebufferAttachmentPoint.Color0, target[i], 0);
                pipeline.Textures[0] = target[i - 1];

                context.DrawElements(BeginMode.Triangles, 6, DrawElementsType.UnsignedShort, 0);
                framebuffer.DetachColorStartingFrom(0);
            }
        }