Home | History | Annotate | Line # | Download | only in d3d12
      1 /*
      2  * Copyright  Microsoft Corporation
      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_SCREEN_H
     25 #define D3D12_SCREEN_H
     26 
     27 #include "pipe/p_screen.h"
     28 
     29 #include "util/slab.h"
     30 #include "d3d12_descriptor_pool.h"
     31 
     32 #ifndef _WIN32
     33 #include <wsl/winadapter.h>
     34 #endif
     35 
     36 #define D3D12_IGNORE_SDK_LAYERS
     37 #include <directx/d3d12.h>
     38 
     39 struct pb_manager;
     40 
     41 enum resource_dimension
     42 {
     43    RESOURCE_DIMENSION_UNKNOWN = 0,
     44    RESOURCE_DIMENSION_BUFFER = 1,
     45    RESOURCE_DIMENSION_TEXTURE1D = 2,
     46    RESOURCE_DIMENSION_TEXTURE2D = 3,
     47    RESOURCE_DIMENSION_TEXTURE2DMS = 4,
     48    RESOURCE_DIMENSION_TEXTURE3D = 5,
     49    RESOURCE_DIMENSION_TEXTURECUBE = 6,
     50    RESOURCE_DIMENSION_TEXTURE1DARRAY = 7,
     51    RESOURCE_DIMENSION_TEXTURE2DARRAY = 8,
     52    RESOURCE_DIMENSION_TEXTURE2DMSARRAY = 9,
     53    RESOURCE_DIMENSION_TEXTURECUBEARRAY = 10,
     54    RESOURCE_DIMENSION_COUNT
     55 };
     56 
     57 struct d3d12_screen {
     58    struct pipe_screen base;
     59    struct sw_winsys *winsys;
     60 
     61    ID3D12Device *dev;
     62    ID3D12CommandQueue *cmdqueue;
     63 
     64    struct slab_parent_pool transfer_pool;
     65    struct pb_manager *bufmgr;
     66    struct pb_manager *cache_bufmgr;
     67    struct pb_manager *slab_bufmgr;
     68    struct pb_manager *readback_slab_bufmgr;
     69 
     70    mtx_t descriptor_pool_mutex;
     71    struct d3d12_descriptor_pool *rtv_pool;
     72    struct d3d12_descriptor_pool *dsv_pool;
     73    struct d3d12_descriptor_pool *view_pool;
     74 
     75    struct d3d12_descriptor_handle null_srvs[RESOURCE_DIMENSION_COUNT];
     76    struct d3d12_descriptor_handle null_rtv;
     77 
     78    /* capabilities */
     79    D3D_FEATURE_LEVEL max_feature_level;
     80    D3D12_FEATURE_DATA_ARCHITECTURE architecture;
     81    D3D12_FEATURE_DATA_D3D12_OPTIONS opts;
     82    D3D12_FEATURE_DATA_D3D12_OPTIONS2 opts2;
     83    D3D12_FEATURE_DATA_D3D12_OPTIONS3 opts3;
     84    D3D12_FEATURE_DATA_D3D12_OPTIONS4 opts4;
     85 
     86    /* description */
     87    uint32_t vendor_id;
     88    uint64_t memory_size_megabytes;
     89    double timestamp_multiplier;
     90    bool have_load_at_vertex;
     91 };
     92 
     93 static inline struct d3d12_screen *
     94 d3d12_screen(struct pipe_screen *pipe)
     95 {
     96    return (struct d3d12_screen *)pipe;
     97 }
     98 
     99 struct d3d12_dxgi_screen {
    100    struct d3d12_screen base;
    101 
    102    struct IDXGIFactory4 *factory;
    103    struct IDXGIAdapter1 *adapter;
    104    wchar_t description[128];
    105 };
    106 
    107 static inline struct d3d12_dxgi_screen *
    108 d3d12_dxgi_screen(struct d3d12_screen *screen)
    109 {
    110    return (struct d3d12_dxgi_screen *)screen;
    111 }
    112 
    113 struct d3d12_dxcore_screen {
    114    struct d3d12_screen base;
    115 
    116    struct IDXCoreAdapterFactory *factory;
    117    struct IDXCoreAdapter *adapter;
    118    char description[256];
    119 };
    120 
    121 static inline struct d3d12_dxcore_screen *
    122 d3d12_dxcore_screen(struct d3d12_screen *screen)
    123 {
    124    return (struct d3d12_dxcore_screen *)screen;
    125 }
    126 
    127 bool
    128 d3d12_init_screen(struct d3d12_screen *screen, struct sw_winsys *winsys, IUnknown *adapter);
    129 
    130 #endif
    131