コード例 #1
0
        public static H1GpuTexture2D Create(Vector4 clearValue, H1Texture2D.Description desc, H1SubresourceData initialData)
        {
            H1GpuTexture2D newTex2D = new H1GpuTexture2D();

            CreatePlatformDependent(clearValue, desc, initialData, ref newTex2D);

            if (newTex2D.Resource == null)
            {
                newTex2D.Destroy();
                return(null);
            }

            return(newTex2D);
        }
コード例 #2
0
 public UInt64 RequestUpload(H1DX12Resource destResource, UInt32 subresource, H1SubresourceData desc, UInt64 size)
 {
     return(0);
 }
コード例 #3
0
        public H1DX12Resource(Resource resource, ResourceStates initialState, ResourceDescription desc, H1SubresourceData[] initialData = null, UInt32 numInitialData = 0)
        {
            m_Resource = resource;
            m_Desc     = desc;

            if (m_Resource != null)
            {
                HeapProperties heapProperties;
                HeapFlags      heapFlag;
                m_Resource.GetHeapProperties(out heapProperties, out heapFlag);

                m_HeapType = heapProperties.Type;

                // certain heaps are restricted to certain 'ResourceStates'
                if (m_HeapType == HeapType.Upload)
                {
                    m_CurrentState = ResourceStates.GenericRead;
                }
                else if (m_HeapType == HeapType.Readback)
                {
                    m_CurrentState = ResourceStates.CopyDestination;
                }
                else
                {
                    m_CurrentState = initialState;
                }

                if (desc.Dimension == ResourceDimension.Buffer)
                {
                    m_GPUVirtualAddress.Ptr = resource.GPUVirtualAddress;
                }
            }
            // null resource put on the UPLOAD heap to prevent attemps to transition the resource
            else
            {
                m_HeapType = HeapType.Upload;
            }

            // defaultly set it as false
            m_bCompressed = false;

            if (initialData != null && numInitialData > 0)
            {
                //@TODO - I need to change this by H1DX12DeviceContext
                //@TODO - I need to move this chunck code to H1DX12DeviceContext as 'UploadResource'
                Device device = H1Global <H1ManagedRenderer> .Instance.Device;

                // create instance of InitialData
                m_InitialData.Size = GetSize(0, numInitialData);
                // create new instance of SubResourceData
                m_InitialData.SubResourceData = new List <H1SubresourceData>();

                for (UInt32 i = 0; i < numInitialData; ++i)
                {
                    H1SubresourceData newInitialData = initialData[i];

                    UInt64 curSize = GetSize(i, 1);
                    UInt64 cpySize = curSize;

                    if (desc.Dimension != ResourceDimension.Texture3D && newInitialData.SlicePitch != 0)
                    {
                        cpySize = newInitialData.SlicePitch;
                        newInitialData.SlicePitch = 0;
                    }
                    else if (desc.Dimension == ResourceDimension.Texture3D && newInitialData.SlicePitch != 0)
                    {
                        cpySize = Convert.ToUInt64((Convert.ToInt32(desc.DepthOrArraySize) >> Convert.ToInt32(i))) * newInitialData.SlicePitch;
                    }

                    newInitialData.pData = SharpDX.Utilities.AllocateMemory(Convert.ToInt32(curSize));
                    SharpDX.Utilities.CopyMemory(newInitialData.pData, initialData[i].pData, Convert.ToInt32(cpySize));
                    m_InitialData.SubResourceData.Add(newInitialData);
                }
            }
        }
コード例 #4
0
        static void CreatePlatformDependent(Vector4 clearValue, H1Texture2D.Description desc, H1SubresourceData initialData, ref H1GpuTexture2D result)
        {
            // get device for directX 12
            Device deviceDX12 = H1Global <H1ManagedRenderer> .Instance.Device;

            H1GpuResourceDesc desc12         = H1RHIDefinitionHelper.Texture2DDescToGpuResourceDesc(desc);
            H1HeapType        heapType       = H1RHIDefinitionHelper.GetHeapTypeFromTexture2DDesc(desc);
            H1ResourceStates  resourceStates = H1RHIDefinitionHelper.GetResourceStatesFromTexture2DDesc(desc);

            // generate resource
            //if (result != null)
            //    result.Resource.CreateResource(heapType, desc12, resourceStates);

            // generate RHI resource description (need resource description for generating UAV or SRV or etc.)
            result.CreateResourceDescription(desc12);
        }