Path: blob/21.2-virgl/src/gallium/drivers/d3d12/d3d12_compiler.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_COMPILER_H24#define D3D12_COMPILER_H2526#include "dxil_nir_lower_int_samplers.h"2728#include "pipe/p_defines.h"29#include "pipe/p_state.h"3031#include "compiler/shader_info.h"32#include "program/prog_statevars.h"3334#include "nir.h"3536struct pipe_screen;3738#ifdef __cplusplus39extern "C" {40#endif4142enum d3d12_state_var {43D3D12_STATE_VAR_Y_FLIP = 0,44D3D12_STATE_VAR_PT_SPRITE,45D3D12_STATE_VAR_FIRST_VERTEX,46D3D12_STATE_VAR_DEPTH_TRANSFORM,47D3D12_MAX_STATE_VARS48};4950#define D3D12_MAX_POINT_SIZE 255.0f5152struct d3d12_validation_tools *d3d12_validator_create();5354void d3d12_validator_destroy(struct d3d12_validation_tools *validator);5556const void *57d3d12_get_compiler_options(struct pipe_screen *screen,58enum pipe_shader_ir ir,59enum pipe_shader_type shader);6061struct d3d12_varying_info {62struct {63const struct glsl_type *type;64unsigned interpolation:3; // INTERP_MODE_COUNT = 565unsigned driver_location:6; // VARYING_SLOT_MAX = 6466} vars[VARYING_SLOT_MAX];67uint64_t mask;68};6970struct d3d12_shader_key {71enum pipe_shader_type stage;7273struct d3d12_varying_info required_varying_inputs;74struct d3d12_varying_info required_varying_outputs;75uint64_t next_varying_inputs;76uint64_t prev_varying_outputs;77unsigned last_vertex_processing_stage : 1;78unsigned invert_depth : 1;79unsigned samples_int_textures : 1;80unsigned tex_saturate_s : PIPE_MAX_SAMPLERS;81unsigned tex_saturate_r : PIPE_MAX_SAMPLERS;82unsigned tex_saturate_t : PIPE_MAX_SAMPLERS;8384struct {85unsigned needs_format_emulation:1;86enum pipe_format format_conversion[PIPE_MAX_ATTRIBS];87} vs;8889struct {90unsigned sprite_coord_enable:24;91unsigned sprite_origin_upper_left:1;92unsigned point_pos_stream_out:1;93unsigned writes_psize:1;94unsigned point_size_per_vertex:1;95unsigned aa_point:1;96unsigned stream_output_factor:3;97unsigned primitive_id:1;98unsigned triangle_strip:1;99} gs;100101struct {102unsigned missing_dual_src_outputs : 2;103unsigned frag_result_color_lowering : 4;104unsigned cast_to_uint : 1;105unsigned cast_to_int : 1;106unsigned provoking_vertex : 2;107unsigned manual_depth_range : 1;108unsigned polygon_stipple : 1;109unsigned remap_front_facing : 1;110} fs;111112int n_texture_states;113dxil_wrap_sampler_state tex_wrap_states[PIPE_MAX_SHADER_SAMPLER_VIEWS];114dxil_texture_swizzle_state swizzle_state[PIPE_MAX_SHADER_SAMPLER_VIEWS];115enum compare_func sampler_compare_funcs[PIPE_MAX_SHADER_SAMPLER_VIEWS];116};117118struct d3d12_shader {119void *bytecode;120size_t bytecode_length;121122nir_shader *nir;123124struct {125unsigned binding;126} cb_bindings[PIPE_MAX_CONSTANT_BUFFERS];127size_t num_cb_bindings;128129struct {130enum d3d12_state_var var;131unsigned offset;132} state_vars[D3D12_MAX_STATE_VARS];133unsigned num_state_vars;134size_t state_vars_size;135bool state_vars_used;136137struct {138int binding;139uint32_t dimension;140} srv_bindings[PIPE_MAX_SHADER_SAMPLER_VIEWS];141size_t begin_srv_binding;142size_t end_srv_binding;143144bool has_default_ubo0;145unsigned pstipple_binding;146147struct d3d12_shader_key key;148struct d3d12_shader *next_variant;149};150151struct d3d12_gs_variant_key152{153unsigned passthrough:1;154unsigned provoking_vertex:3;155unsigned alternate_tri:1;156unsigned fill_mode:2;157unsigned cull_mode:2;158unsigned has_front_face:1;159unsigned front_ccw:1;160unsigned edge_flag_fix:1;161unsigned flatshade_first:1;162uint64_t flat_varyings;163struct d3d12_varying_info varyings;164};165166struct d3d12_shader_selector {167enum pipe_shader_type stage;168nir_shader *initial;169struct d3d12_shader *first;170struct d3d12_shader *current;171172struct pipe_stream_output_info so_info;173174unsigned samples_int_textures:1;175unsigned compare_with_lod_bias_grad:1;176177bool is_gs_variant;178struct d3d12_gs_variant_key gs_key;179};180181struct d3d12_context;182183struct d3d12_shader_selector *184d3d12_create_shader(struct d3d12_context *ctx,185enum pipe_shader_type stage,186const struct pipe_shader_state *shader);187188void189d3d12_shader_free(struct d3d12_shader_selector *shader);190191void192d3d12_select_shader_variants(struct d3d12_context *ctx,193const struct pipe_draw_info *dinfo);194195void196d3d12_gs_variant_cache_init(struct d3d12_context *ctx);197198void199d3d12_gs_variant_cache_destroy(struct d3d12_context *ctx);200201struct d3d12_shader_selector *202d3d12_get_gs_variant(struct d3d12_context *ctx, struct d3d12_gs_variant_key *key);203204#ifdef __cplusplus205}206#endif207208#endif209210211