// generic version for page creation protected virtual Boolean CreatePage(Int64 sizeInBytes, H1OptionalParameters options = null) { // invalid call for create page if (Owner.PageType != H1GpuMemoryPageType.Normal) { return(false); } // create resource encapsulated GPU API layer H1HeapType heapType = H1HeapType.Unknown; H1ResourceStates usage = H1ResourceStates.Invalid; H1GpuResourceDesc resourceDesc = new H1GpuResourceDesc(); resourceDesc.Alignment = 0; // depends on GDI decision for choosing appropriate alignment resourceDesc.Height = 1; resourceDesc.DepthOrArraySize = 1; resourceDesc.MipLevels = 1; resourceDesc.Format = H1PixelFormat.Unknown; resourceDesc.SampleDesc.Count = 1; resourceDesc.SampleDesc.Quality = 0; resourceDesc.Layout = H1TextureLayout.RowMajor; if (Owner.Type != H1GpuMemoryType.GpuWritable) { // invalid gpu memory type // CpuWritable type should be H1GpuMemoryPageSegmented type return(false); } // GPU-writable heapType = H1HeapType.Default; resourceDesc.Width = Convert.ToUInt32(sizeInBytes); // apply optional parameters if (options != null) { resourceDesc.Flags = options.ResourceFlags; usage = options.ResourceStates; } // create new page resource //if (!Resource.CreateResource(heapType, resourceDesc, usage)) { return(false); } //return true; }
public static H1GpuMemoryPageBuffer CreatePage(H1GpuMemoryChunk memoryChunk, Int64 sizeInBytes, H1OptionalParameters options = null) { H1GpuMemoryPageBuffer newGpuMemoryPageBuffer = new H1GpuMemoryPageBuffer(memoryChunk); if (!newGpuMemoryPageBuffer.CreatePage(sizeInBytes, options)) { return(null); } return(newGpuMemoryPageBuffer); }