/// <summary> /// Function to initialize the view. /// </summary> private protected override D3D11.ResourceView OnCreateNativeView() { Graphics.Log.Print($"Creating D3D11 buffer shader resource view for {Buffer.Name}.", LoggingLevel.Simple); var desc = new D3D11.ShaderResourceViewDescription1 { Format = (Format)Format, Dimension = D3D.ShaderResourceViewDimension.ExtendedBuffer, BufferEx = new D3D11.ShaderResourceViewDescription.ExtendedBufferResource { FirstElement = StartElement, ElementCount = ElementCount, Flags = D3D11.ShaderResourceViewExtendedBufferFlags.None } }; // Create our SRV. Native = new D3D11.ShaderResourceView1(Buffer.Graphics.D3DDevice, Buffer.D3DResource, desc) { DebugName = $"'{Buffer.Name}'_D3D11ShaderResourceView1_Buffer" }; Graphics.Log.Print($"Shader Resource Buffer View '{Buffer.Name}': {Buffer.ResourceType} -> Start: {StartElement}, Count: {ElementCount}, Element Size: {ElementSize}", LoggingLevel.Verbose); return(Native); }
/// <summary> /// Function to initialize the shader resource view. /// </summary> /// <returns>The view that was created.</returns> private protected override D3D11.ResourceView OnCreateNativeView() { D3D11.ShaderResourceViewDescription1 desc = IsCubeMap ? GetDesc2DCube() : GetDesc2D(); try { Graphics.Log.Print($"Creating D3D11 2D texture shader resource view for {Texture.Name}.", LoggingLevel.Simple); // Create our SRV. Native = new D3D11.ShaderResourceView1(Texture.Graphics.D3DDevice, Texture.D3DResource, desc) { DebugName = $"'{Texture.Name}'_D3D11ShaderResourceView1_2D" }; Graphics.Log.Print($"Shader Resource View '{Texture.Name}': {Texture.ResourceType} -> Mip slice: {MipSlice}, Array Index: {ArrayIndex}, Array Count: {ArrayCount}, Cube Map: {IsCubeMap}", LoggingLevel.Verbose); } catch (DX.SharpDXException sDXEx) { if ((uint)sDXEx.ResultCode.Code == 0x80070057) { throw new GorgonException(GorgonResult.CannotCreate, string.Format(Resources.GORGFX_ERR_VIEW_CANNOT_CAST_FORMAT, Texture.Format, Format)); } throw; } return(Native); }
/// <summary> /// Function to perform the creation of a specific kind of view. /// </summary> /// <returns>The view that was created.</returns> private protected override D3D11.ResourceView OnCreateNativeView() { var desc = new D3D11.ShaderResourceViewDescription1 { Format = (Format)Format, Dimension = Texture.ArrayCount > 1 ? D3D.ShaderResourceViewDimension.Texture1DArray : D3D.ShaderResourceViewDimension.Texture1D, Texture1DArray = { MipLevels = MipCount, MostDetailedMip = MipSlice, FirstArraySlice = ArrayIndex, ArraySize = ArrayCount } }; try { Graphics.Log.Print($"Creating D3D11 1D texture shader resource view for {Texture.Name}.", LoggingLevel.Simple); // Create our SRV. Native = new D3D11.ShaderResourceView1(Texture.Graphics.D3DDevice, Texture.D3DResource, desc) { DebugName = $"'{Texture.Name}'_D3D11ShaderResourceView1_1D" }; Graphics.Log.Print($"Shader Resource View '{Texture.Name}': {Texture.ResourceType} -> Mip slice: {MipSlice}, Array Index: {ArrayIndex}, Array Count: {ArrayCount}", LoggingLevel.Verbose); } catch (DX.SharpDXException sDXEx) { if ((uint)sDXEx.ResultCode.Code == 0x80070057) { throw new GorgonException(GorgonResult.CannotCreate, string.Format(Resources.GORGFX_ERR_VIEW_CANNOT_CAST_FORMAT, Texture.Format, Format)); } throw; } return(Native); }
/// <summary> /// Function to initialize the buffer view. /// </summary> private protected override D3D11.ResourceView OnCreateNativeView() { Graphics.Log.Print($"Creating D3D11 raw buffer shader resource view for {Buffer.Name}.", LoggingLevel.Simple); BufferFormat format = BufferFormat.Unknown; switch (ElementType) { case RawBufferElementType.Int32: format = BufferFormat.R32_SInt; break; case RawBufferElementType.UInt32: format = BufferFormat.R32_UInt; break; case RawBufferElementType.Single: format = BufferFormat.R32_Float; break; } var desc = new D3D11.ShaderResourceViewDescription1 { Format = (Format)format, Dimension = ShaderResourceViewDimension.ExtendedBuffer, BufferEx = new D3D11.ShaderResourceViewDescription.ExtendedBufferResource { FirstElement = StartElement, ElementCount = ElementCount, Flags = D3D11.ShaderResourceViewExtendedBufferFlags.Raw } }; // Create our SRV. Native = new D3D11.ShaderResourceView1(Buffer.Graphics.D3DDevice, Buffer.D3DResource, desc) { DebugName = $"'{Buffer.Name}'_D3D11ShaderResourceView1_Raw" }; Graphics.Log.Print($"Shader Resource Raw Buffer View '{Buffer.Name}': {Buffer.ResourceType} -> Start: {StartElement}, Count: {ElementCount}, Element Size: {ElementSize}, ElementType(Format): {ElementType}({format})", LoggingLevel.Verbose); return(Native); }