1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © Microsoft Corporation 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21bf215546Sopenharmony_ci * IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#ifndef DZN_NIR_H 25bf215546Sopenharmony_ci#define DZN_NIR_H 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_ci#define D3D12_IGNORE_SDK_LAYERS 28bf215546Sopenharmony_ci#define COBJMACROS 29bf215546Sopenharmony_ci#include <unknwn.h> 30bf215546Sopenharmony_ci#include <directx/d3d12.h> 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ci#include "nir.h" 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_cistruct dzn_indirect_draw_params { 35bf215546Sopenharmony_ci uint32_t vertex_count; 36bf215546Sopenharmony_ci uint32_t instance_count; 37bf215546Sopenharmony_ci uint32_t first_vertex; 38bf215546Sopenharmony_ci uint32_t first_instance; 39bf215546Sopenharmony_ci}; 40bf215546Sopenharmony_ci 41bf215546Sopenharmony_cistruct dzn_indirect_indexed_draw_params { 42bf215546Sopenharmony_ci uint32_t index_count; 43bf215546Sopenharmony_ci uint32_t instance_count; 44bf215546Sopenharmony_ci uint32_t first_index; 45bf215546Sopenharmony_ci int32_t vertex_offset; 46bf215546Sopenharmony_ci uint32_t first_instance; 47bf215546Sopenharmony_ci}; 48bf215546Sopenharmony_ci 49bf215546Sopenharmony_cistruct dzn_indirect_draw_rewrite_params { 50bf215546Sopenharmony_ci uint32_t draw_buf_stride; 51bf215546Sopenharmony_ci}; 52bf215546Sopenharmony_ci 53bf215546Sopenharmony_cistruct dzn_indirect_draw_triangle_fan_rewrite_params { 54bf215546Sopenharmony_ci uint32_t draw_buf_stride; 55bf215546Sopenharmony_ci uint32_t triangle_fan_index_buf_stride; 56bf215546Sopenharmony_ci uint64_t triangle_fan_index_buf_start; 57bf215546Sopenharmony_ci}; 58bf215546Sopenharmony_ci 59bf215546Sopenharmony_cistruct dzn_indirect_draw_triangle_fan_prim_restart_rewrite_params { 60bf215546Sopenharmony_ci uint32_t draw_buf_stride; 61bf215546Sopenharmony_ci uint32_t triangle_fan_index_buf_stride; 62bf215546Sopenharmony_ci uint64_t triangle_fan_index_buf_start; 63bf215546Sopenharmony_ci uint64_t exec_buf_start; 64bf215546Sopenharmony_ci}; 65bf215546Sopenharmony_ci 66bf215546Sopenharmony_cistruct dzn_indirect_draw_exec_params { 67bf215546Sopenharmony_ci struct { 68bf215546Sopenharmony_ci uint32_t first_vertex; 69bf215546Sopenharmony_ci uint32_t base_instance; 70bf215546Sopenharmony_ci uint32_t draw_id; 71bf215546Sopenharmony_ci } sysvals; 72bf215546Sopenharmony_ci union { 73bf215546Sopenharmony_ci struct dzn_indirect_draw_params draw; 74bf215546Sopenharmony_ci struct dzn_indirect_indexed_draw_params indexed_draw; 75bf215546Sopenharmony_ci }; 76bf215546Sopenharmony_ci}; 77bf215546Sopenharmony_ci 78bf215546Sopenharmony_cistruct dzn_indirect_triangle_fan_draw_exec_params { 79bf215546Sopenharmony_ci D3D12_INDEX_BUFFER_VIEW ibview; 80bf215546Sopenharmony_ci struct { 81bf215546Sopenharmony_ci uint32_t first_vertex; 82bf215546Sopenharmony_ci uint32_t base_instance; 83bf215546Sopenharmony_ci uint32_t draw_id; 84bf215546Sopenharmony_ci } sysvals; 85bf215546Sopenharmony_ci union { 86bf215546Sopenharmony_ci struct dzn_indirect_draw_params draw; 87bf215546Sopenharmony_ci struct dzn_indirect_indexed_draw_params indexed_draw; 88bf215546Sopenharmony_ci }; 89bf215546Sopenharmony_ci}; 90bf215546Sopenharmony_ci 91bf215546Sopenharmony_cistruct dzn_triangle_fan_rewrite_index_params { 92bf215546Sopenharmony_ci uint32_t first_index; 93bf215546Sopenharmony_ci}; 94bf215546Sopenharmony_ci 95bf215546Sopenharmony_cistruct dzn_triangle_fan_prim_restart_rewrite_index_params { 96bf215546Sopenharmony_ci uint32_t first_index; 97bf215546Sopenharmony_ci uint32_t index_count; 98bf215546Sopenharmony_ci}; 99bf215546Sopenharmony_ci 100bf215546Sopenharmony_cistruct dzn_indirect_triangle_fan_rewrite_index_exec_params { 101bf215546Sopenharmony_ci uint64_t new_index_buf; 102bf215546Sopenharmony_ci struct dzn_triangle_fan_rewrite_index_params params; 103bf215546Sopenharmony_ci struct { 104bf215546Sopenharmony_ci uint32_t x, y, z; 105bf215546Sopenharmony_ci } group_count; 106bf215546Sopenharmony_ci}; 107bf215546Sopenharmony_ci 108bf215546Sopenharmony_cistruct dzn_indirect_triangle_fan_prim_restart_rewrite_index_exec_params { 109bf215546Sopenharmony_ci uint64_t new_index_buf; 110bf215546Sopenharmony_ci struct dzn_triangle_fan_prim_restart_rewrite_index_params params; 111bf215546Sopenharmony_ci uint64_t index_count_ptr; 112bf215546Sopenharmony_ci struct { 113bf215546Sopenharmony_ci uint32_t x, y, z; 114bf215546Sopenharmony_ci } group_count; 115bf215546Sopenharmony_ci}; 116bf215546Sopenharmony_ci 117bf215546Sopenharmony_cienum dzn_indirect_draw_type { 118bf215546Sopenharmony_ci DZN_INDIRECT_DRAW, 119bf215546Sopenharmony_ci DZN_INDIRECT_DRAW_COUNT, 120bf215546Sopenharmony_ci DZN_INDIRECT_INDEXED_DRAW, 121bf215546Sopenharmony_ci DZN_INDIRECT_INDEXED_DRAW_COUNT, 122bf215546Sopenharmony_ci DZN_INDIRECT_DRAW_TRIANGLE_FAN, 123bf215546Sopenharmony_ci DZN_INDIRECT_DRAW_COUNT_TRIANGLE_FAN, 124bf215546Sopenharmony_ci DZN_INDIRECT_INDEXED_DRAW_TRIANGLE_FAN, 125bf215546Sopenharmony_ci DZN_INDIRECT_INDEXED_DRAW_COUNT_TRIANGLE_FAN, 126bf215546Sopenharmony_ci DZN_INDIRECT_INDEXED_DRAW_TRIANGLE_FAN_PRIM_RESTART, 127bf215546Sopenharmony_ci DZN_INDIRECT_INDEXED_DRAW_COUNT_TRIANGLE_FAN_PRIM_RESTART, 128bf215546Sopenharmony_ci DZN_NUM_INDIRECT_DRAW_TYPES, 129bf215546Sopenharmony_ci}; 130bf215546Sopenharmony_ci 131bf215546Sopenharmony_cinir_shader * 132bf215546Sopenharmony_cidzn_nir_indirect_draw_shader(enum dzn_indirect_draw_type type); 133bf215546Sopenharmony_ci 134bf215546Sopenharmony_cinir_shader * 135bf215546Sopenharmony_cidzn_nir_triangle_fan_rewrite_index_shader(uint8_t old_index_size); 136bf215546Sopenharmony_ci 137bf215546Sopenharmony_cinir_shader * 138bf215546Sopenharmony_cidzn_nir_triangle_fan_prim_restart_rewrite_index_shader(uint8_t old_index_size); 139bf215546Sopenharmony_ci 140bf215546Sopenharmony_cistruct dzn_nir_blit_info { 141bf215546Sopenharmony_ci union { 142bf215546Sopenharmony_ci struct { 143bf215546Sopenharmony_ci uint32_t src_samples : 6; 144bf215546Sopenharmony_ci uint32_t loc : 4; 145bf215546Sopenharmony_ci uint32_t out_type : 4; 146bf215546Sopenharmony_ci uint32_t sampler_dim : 4; 147bf215546Sopenharmony_ci uint32_t src_is_array : 1; 148bf215546Sopenharmony_ci uint32_t resolve : 1; 149bf215546Sopenharmony_ci uint32_t padding : 12; 150bf215546Sopenharmony_ci }; 151bf215546Sopenharmony_ci const uint32_t hash_key; 152bf215546Sopenharmony_ci }; 153bf215546Sopenharmony_ci}; 154bf215546Sopenharmony_ci 155bf215546Sopenharmony_cinir_shader * 156bf215546Sopenharmony_cidzn_nir_blit_vs(void); 157bf215546Sopenharmony_ci 158bf215546Sopenharmony_cinir_shader * 159bf215546Sopenharmony_cidzn_nir_blit_fs(const struct dzn_nir_blit_info *info); 160bf215546Sopenharmony_ci 161bf215546Sopenharmony_ci#endif 162