Path: blob/21.2-virgl/src/gallium/drivers/d3d12/d3d12_descriptor_pool.h
4570 views
/*1* Copyright © Microsoft Corporation2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*/2223#ifndef D3D12_DESCRIPTOR_POOL_H24#define D3D12_DESCRIPTOR_POOL_H2526#ifndef _WIN3227#include <wsl/winadapter.h>28#endif2930#define D3D12_IGNORE_SDK_LAYERS31#include <directx/d3d12.h>3233struct d3d12_descriptor_pool;34struct d3d12_descriptor_heap;3536struct d3d12_descriptor_handle {37D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle;38D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle;39struct d3d12_descriptor_heap *heap;40};4142inline bool43d3d12_descriptor_handle_is_allocated(struct d3d12_descriptor_handle *handle)44{45return (handle->heap != NULL);46}4748void49d3d12_descriptor_handle_free(struct d3d12_descriptor_handle *handle);5051/* Offline Descriptor Pool */5253struct d3d12_descriptor_pool*54d3d12_descriptor_pool_new(struct d3d12_screen *screen,55D3D12_DESCRIPTOR_HEAP_TYPE type,56uint32_t num_descriptors);5758void59d3d12_descriptor_pool_free(struct d3d12_descriptor_pool *pool);6061uint32_t62d3d12_descriptor_pool_alloc_handle(struct d3d12_descriptor_pool *pool,63struct d3d12_descriptor_handle *handle);646566/* Online/Offline Descriptor Heaps */6768struct d3d12_descriptor_heap*69d3d12_descriptor_heap_new(ID3D12Device *device,70D3D12_DESCRIPTOR_HEAP_TYPE type,71D3D12_DESCRIPTOR_HEAP_FLAGS flags,72uint32_t num_descriptors);7374void75d3d12_descriptor_heap_free(struct d3d12_descriptor_heap *heap);7677ID3D12DescriptorHeap*78d3d12_descriptor_heap_get(struct d3d12_descriptor_heap *heap);7980void81d2d12_descriptor_heap_get_next_handle(struct d3d12_descriptor_heap *heap,82struct d3d12_descriptor_handle *handle);8384uint32_t85d3d12_descriptor_heap_get_remaining_handles(struct d3d12_descriptor_heap *heap);8687uint32_t88d3d12_descriptor_heap_alloc_handle(struct d3d12_descriptor_heap *heap,89struct d3d12_descriptor_handle *handle);9091void92d3d12_descriptor_heap_append_handles(struct d3d12_descriptor_heap *heap,93D3D12_CPU_DESCRIPTOR_HANDLE *handles,94unsigned num_handles);9596void97d3d12_descriptor_heap_clear(struct d3d12_descriptor_heap *heap);9899#endif100101102