public VideoTextures(ITexture luma, ITexture chroma) { m_luma = luma; m_chroma = chroma; this.luma = luma.GetDefaultView(TextureViewType.ShaderResource); this.chroma = chroma.GetDefaultView(TextureViewType.ShaderResource); }
public Nv12Texture(ITexture texture) { this.texture = texture; view = texture.GetDefaultView(TextureViewType.ShaderResource); if (null == view) { throw new ApplicationException("The NV12 texture doesn't have a shader resource view"); } }
// SavePngFrames savePng; protected override ITextureView createOutputTexture(IRenderDevice device, TextureFormat format, CSize size) { outputSize = size; TextureDesc desc = new TextureDesc(false) { Type = ResourceDimension.Tex2d, BindFlags = BindFlags.ShaderResource | BindFlags.RenderTarget, Format = format, Size = size }; frameTexture = device.CreateTexture(ref desc, $"Video frame RGB"); frameRtv = frameTexture.GetDefaultView(TextureViewType.RenderTarget); rgbFormat = format; // savePng = new SavePngFrames(); return(frameTexture.GetDefaultView(TextureViewType.ShaderResource)); }
public PaletteTexture(Context context) { this.context = context; var desc = textureDesc(1); using (var dev = context.device) texture = dev.CreateTexture(ref desc, "Palette"); m_textureView = texture.GetDefaultView(TextureViewType.ShaderResource); textureRows = 1; // Add just a few hardcoded colors, with names matching eNamedColor enum Palette.PredefinedPaletteEntries.initPalette(colorIndices); }
static ITextureView loadBmp(IRenderDevice device, byte[] payload, ref BITMAPINFOHEADER header, CSize size, out bool monochrome) { if (header.biWidth != size.cx) { throw new ArgumentException("Size in BMP doesn't match"); } uint[] rgba; if (header.biCompression == BitmapCompressionMode.BI_RGB && header.biHeight == size.cy * 2) { if (header.biBitCount == 32) { monochrome = false; rgba = decodeRgbIcon(payload, size); } else if (header.biBitCount == 1) { monochrome = true; return(Monochrome.load(device, payload, size)); } else { throw new NotImplementedException(); } } else { throw new NotImplementedException(); } TextureDesc desc = new TextureDesc(false); desc.Type = ResourceDimension.Tex2d; desc.Size = size; if (RuntimeEnvironment.operatingSystem == eOperatingSystem.Windows) { desc.Format = TextureFormat.Bgra8Unorm; } else { desc.Format = TextureFormat.Rgba8Unorm; GraphicsUtils.swapRedBlueChannels(rgba); } desc.Usage = Usage.Static; desc.BindFlags = BindFlags.ShaderResource; ITexture texture = device.CreateTexture(ref desc, rgba, size.cx * 4, "Mouse cursor"); return(texture.GetDefaultView(TextureViewType.ShaderResource)); }
public static ITextureView load(IRenderDevice device, byte[] payload, CSize size) { byte[] data = decodeMonochromeIcon(payload, size); TextureDesc desc = new TextureDesc(false); desc.Type = ResourceDimension.Tex2d; desc.Size = size; desc.Format = TextureFormat.R8Unorm; desc.Usage = Usage.Static; desc.BindFlags = BindFlags.ShaderResource; ITexture texture = device.CreateTexture(ref desc, data, size.cx, "Monochrome cursor"); return(texture.GetDefaultView(TextureViewType.ShaderResource)); }
public void blend(Context context, ITextureView destRgb, ITextureView destDepth, Blender blender) { // BTW, the ability to read from multi-sampled textures appeared in GLES 3.1, just in time: // https://www.khronos.org/registry/OpenGL-Refpages/es3.1/html/texelFetch.xhtml if (null == blenderBinding) { using (var resourceView = texture.GetDefaultView(TextureViewType.ShaderResource)) blenderBinding = blender.bindSource(resourceView); } var ic = context.context; ic.SetRenderTarget(destRgb, destDepth); blender.blend(ic, blenderBinding); }
public RenderTarget(Context context, CSize size, TextureFormat format, int sampleCount, string name) { this.size = size; TextureDesc desc = new TextureDesc(false); desc.Type = ResourceDimension.Tex2d; desc.Size = size; desc.Format = format; desc.SampleCount = (uint)sampleCount; desc.BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource; using (var device = context.renderContext.device) texture = device.CreateTexture(ref desc, name); targetView = texture.GetDefaultView(TextureViewType.RenderTarget); }