public H1VertexStreamComponent(H1VertexStreamSematicType type, H1VertexElementType elementType, int offset) { m_VertexStreamComponentType = type; m_VertexElementType = elementType; m_Stride = Convert.ToInt32(H1RHIDefinitionHelper.ElementTypeToSize(elementType)); m_Offset = offset; }
public H1Texture2D(H1GPUResourceManager manager, uint index, H1PixelFormat elementType, int width, int height) : base(manager, Convert.ToUInt32(H1RHIDefinitionHelper.ElementTypeToSize(elementType) * width * height)) { m_Index = index; m_Description.Format = elementType; m_Description.Width = Convert.ToUInt32(width); m_Description.Height = Convert.ToUInt32(height); // @TODO - I need to add initial variables like NumMips, NumSamples and TextureName }
public static SharpDX.Direct3D12.ClearValue FormatToClearValue(H1PixelFormat pixelFormat, Boolean bDepth) { SharpDX.Direct3D12.ClearValue clearValue; clearValue.Color.X = 0.0f; clearValue.Color.Y = 0.0f; clearValue.Color.Z = 0.0f; clearValue.Color.W = 0.0f; clearValue.Format = H1RHIDefinitionHelper.ConvertToFormat(pixelFormat); if (clearValue.Format == SharpDX.DXGI.Format.R32_Typeless) { clearValue.Format = bDepth ? SharpDX.DXGI.Format.D32_Float : SharpDX.DXGI.Format.R32_Float; } clearValue.DepthStencil.Depth = 0.0f; clearValue.DepthStencil.Stencil = 0; return(clearValue); }
public void CopyTextureRegion(H1Texture2D texObject, H1GeneralBuffer generalBuffer) { // reuse the memory associated with command recording // we can only reset when the associated command lists have finished execution on the GPU m_CommandList.CommandAllocator.Reset(); // a command list can be reset after it has been added to the command queue via ExecuteCommandList m_CommandList.CommandList.Reset(m_CommandList.CommandAllocator, null); // @TODO - I need to change this into parallel copy texture region by managing multiple command queue H1GPUResourceManager refResourceManager = H1Global <H1ManagedRenderer> .Instance.ResourceManager; // create destination and source locations // TextureCopyLocation - describe a portion of texture for the purpose of texture copies TextureCopyLocation destLocation = new TextureCopyLocation(refResourceManager.GetTexture2D(Convert.ToInt32(texObject.Index)), 0); TextureCopyLocation srcLocation = new TextureCopyLocation(generalBuffer.Resource, new PlacedSubResourceFootprint() // describes the footprint of a placed subresource, including the offset and the D3D12_SUBRESOURCE_FOOTPRINT { Offset = 0, // the offset of the subresource within the parent resource in bytes Footprint = new SubResourceFootprint() // describes the format, with, height, depth and row-pitch of the subresource into the parent resource { Width = Convert.ToInt32(texObject.Width), Height = Convert.ToInt32(texObject.Height), Depth = 1, Format = H1RHIDefinitionHelper.ConvertToFormat(texObject.PixelFormat), RowPitch = Convert.ToInt32(texObject.Stride), } }); m_CommandList.CommandList.ResourceBarrierTransition(texObject.Resource, ResourceStates.GenericRead, ResourceStates.CopyDestination); m_CommandList.CommandList.CopyTextureRegion(destLocation, 0, 0, 0, srcLocation, null); m_CommandList.CommandList.ResourceBarrierTransition(texObject.Resource, ResourceStates.CopyDestination, ResourceStates.GenericRead); m_CommandList.CommandList.Close(); m_DeviceContext.MainCommandListPool.CommandQueue.ExecuteCommandList(m_CommandList.CommandList); }