1 /* 2 * Copyright 2008 Corbin Simpson <[email protected]> 3 * Joakim Sindholt <[email protected]> 4 * Copyright 2009 Marek Olšák <[email protected]> 5 * SPDX-License-Identifier: MIT 6 */ 7 8 #ifndef R300_FS_H 9 #define R300_FS_H 10 11 #include "pipe/p_state.h" 12 #include "tgsi/tgsi_scan.h" 13 #include "compiler/radeon_code.h" 14 #include "r300_shader_semantics.h" 15 16 struct r300_fragment_shader_code { 17 struct rX00_fragment_program_code code; 18 struct tgsi_shader_info info; 19 struct r300_shader_semantics inputs; 20 21 /* Whether the shader was replaced by a dummy one due to a shader 22 * compilation failure. */ 23 bool dummy; 24 25 /* Numbers of constants for each type. */ 26 unsigned externals_count; 27 unsigned immediates_count; 28 unsigned rc_state_count; 29 30 /* Registers for fragment depth output setup. */ 31 uint32_t fg_depth_src; /* R300_FG_DEPTH_SRC: 0x4bd8 */ 32 uint32_t us_out_w; /* R300_US_W_FMT: 0x46b4 */ 33 34 struct r300_fragment_program_external_state compare_state; 35 36 unsigned cb_code_size; 37 uint32_t *cb_code; 38 39 struct r300_fragment_shader_code* next; 40 41 bool write_all; 42 43 }; 44 45 struct r300_fragment_shader { 46 /* Parent class */ 47 struct pipe_shader_state state; 48 49 /* Currently-bound fragment shader. */ 50 struct r300_fragment_shader_code* shader; 51 52 /* List of the same shaders compiled with different texture-compare 53 * states. */ 54 struct r300_fragment_shader_code* first; 55 }; 56 57 void r300_shader_read_fs_inputs(struct tgsi_shader_info* info, 58 struct r300_shader_semantics* fs_inputs); 59 60 /* Return TRUE if the shader was switched and should be re-emitted. */ 61 bool r300_pick_fragment_shader(struct r300_context *r300, 62 struct r300_fragment_shader* fs, 63 struct r300_fragment_program_external_state *state); 64 void r300_fragment_program_get_external_state(struct r300_context *r300, 65 struct r300_fragment_program_external_state *state); 66 r300_fragment_shader_writes_depth(struct r300_fragment_shader * fs)67static inline bool r300_fragment_shader_writes_depth(struct r300_fragment_shader *fs) 68 { 69 if (!fs) 70 return false; 71 return (fs->shader->code.writes_depth) ? true : false; 72 } 73 r300_fragment_shader_writes_all(struct r300_fragment_shader * fs)74static inline bool r300_fragment_shader_writes_all(struct r300_fragment_shader *fs) 75 { 76 if (!fs) 77 return false; 78 return (fs->shader->write_all) ? true : false; 79 } 80 #endif /* R300_FS_H */ 81