1/* 2 * Copyright © Yonggang Luo 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 */ 23 24#ifndef D3D12_COMMON_STATE_H 25#define D3D12_COMMON_STATE_H 26 27#pragma once 28 29#ifndef _WIN32 30#include <wsl/winadapter.h> 31#else 32#include <unknwn.h> 33#endif 34 35#define D3D12_IGNORE_SDK_LAYERS 36#include <directx/d3d12.h> 37#include <directx/d3d12video.h> 38 39#if defined(__cplusplus) 40#if !defined(_WIN32) || defined(_MSC_VER) || D3D12_SDK_VERSION < 606 41inline D3D12_CPU_DESCRIPTOR_HANDLE 42GetCPUDescriptorHandleForHeapStart(ID3D12DescriptorHeap *heap) 43{ 44 return heap->GetCPUDescriptorHandleForHeapStart(); 45} 46inline D3D12_GPU_DESCRIPTOR_HANDLE 47GetGPUDescriptorHandleForHeapStart(ID3D12DescriptorHeap *heap) 48{ 49 return heap->GetGPUDescriptorHandleForHeapStart(); 50} 51inline D3D12_RESOURCE_DESC 52GetDesc(ID3D12Resource *res) 53{ 54 return res->GetDesc(); 55} 56inline D3D12_HEAP_PROPERTIES 57GetCustomHeapProperties(ID3D12Device *dev, D3D12_HEAP_TYPE type) 58{ 59 return dev->GetCustomHeapProperties(0, type); 60} 61inline LUID 62GetAdapterLuid(ID3D12Device *dev) 63{ 64 return dev->GetAdapterLuid(); 65} 66inline D3D12_VIDEO_PROCESS_OUTPUT_STREAM_DESC 67GetOutputStreamDesc(ID3D12VideoProcessor *proc) 68{ 69 return proc->GetOutputStreamDesc(); 70} 71#else 72inline D3D12_CPU_DESCRIPTOR_HANDLE 73GetCPUDescriptorHandleForHeapStart(ID3D12DescriptorHeap *heap) 74{ 75 D3D12_CPU_DESCRIPTOR_HANDLE ret; 76 heap->GetCPUDescriptorHandleForHeapStart(&ret); 77 return ret; 78} 79inline D3D12_GPU_DESCRIPTOR_HANDLE 80GetGPUDescriptorHandleForHeapStart(ID3D12DescriptorHeap *heap) 81{ 82 D3D12_GPU_DESCRIPTOR_HANDLE ret; 83 heap->GetGPUDescriptorHandleForHeapStart(&ret); 84 return ret; 85} 86inline D3D12_RESOURCE_DESC 87GetDesc(ID3D12Resource *res) 88{ 89 D3D12_RESOURCE_DESC ret; 90 res->GetDesc(&ret); 91 return ret; 92} 93inline D3D12_HEAP_PROPERTIES 94GetCustomHeapProperties(ID3D12Device *dev, D3D12_HEAP_TYPE type) 95{ 96 D3D12_HEAP_PROPERTIES ret; 97 dev->GetCustomHeapProperties(&ret, 0, type); 98 return ret; 99} 100inline LUID 101GetAdapterLuid(ID3D12Device *dev) 102{ 103 LUID ret; 104 dev->GetAdapterLuid(&ret); 105 return ret; 106} 107inline D3D12_VIDEO_PROCESS_OUTPUT_STREAM_DESC 108GetOutputStreamDesc(ID3D12VideoProcessor *proc) 109{ 110 D3D12_VIDEO_PROCESS_OUTPUT_STREAM_DESC ret; 111 proc->GetOutputStreamDesc(&ret); 112 return ret; 113} 114#endif 115#endif 116 117#endif 118