1 /* 2 * Copyright © 2023 Valve 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 LP_SAMPLER_MATRIX 25 #define LP_SAMPLER_MATRIX 26 27 #include "util/bitset.h" 28 #include "util/u_dynarray.h" 29 #include "util/format/u_format.h" 30 #include "util/simple_mtx.h" 31 #include "gallivm/lp_bld_sample.h" 32 #include "gallivm/lp_bld_jit_sample.h" 33 34 #define LP_SAMPLE_KEY_COUNT (1 << 11) 35 36 struct lp_sampler_matrix { 37 struct lp_texture_functions **textures; 38 struct lp_static_sampler_state *samplers; 39 40 uint32_t texture_count; 41 uint32_t sampler_count; 42 43 BITSET_DECLARE(sample_keys, LP_SAMPLE_KEY_COUNT); 44 BITSET_DECLARE(image_ops, LP_TOTAL_IMAGE_OP_COUNT); 45 46 /* Per sample key functions which compile and cache sample functions on demand. */ 47 void *jit_sample_functions[LP_SAMPLE_KEY_COUNT]; 48 void *compile_function; 49 struct hash_table *cache; 50 simple_mtx_t lock; 51 52 struct llvmpipe_context *ctx; 53 54 struct util_dynarray gallivms; 55 }; 56 57 void llvmpipe_init_sampler_matrix(struct llvmpipe_context *ctx); 58 59 void llvmpipe_sampler_matrix_destroy(struct llvmpipe_context *ctx); 60 61 void llvmpipe_register_shader(struct pipe_context *ctx, const struct pipe_shader_state *shader); 62 63 void llvmpipe_clear_sample_functions_cache(struct llvmpipe_context *ctx, struct pipe_fence_handle **fence); 64 65 #endif /* LP_SAMPLER_MATRIX */ 66