Path: blob/21.2-virgl/src/gallium/drivers/swr/swr_shader.h
4570 views
/****************************************************************************1* Copyright (C) 2015 Intel Corporation. All Rights Reserved.2*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#pragma once2425struct swr_vertex_shader;26struct swr_fragment_shader;27struct swr_geometry_shader;28struct swr_tess_control_shader;29struct swr_tess_evaluation_shader;3031struct swr_jit_fs_key;32struct swr_jit_vs_key;33struct swr_jit_gs_key;34struct swr_jit_tcs_key;35struct swr_jit_tes_key;3637using PFN_TCS_FUNC = PFN_HS_FUNC;38using PFN_TES_FUNC = PFN_DS_FUNC;3940unsigned swr_so_adjust_attrib(unsigned in_attrib,41swr_vertex_shader *swr_vs);4243PFN_VERTEX_FUNC44swr_compile_vs(struct swr_context *ctx, swr_jit_vs_key &key);4546PFN_PIXEL_KERNEL47swr_compile_fs(struct swr_context *ctx, swr_jit_fs_key &key);4849PFN_GS_FUNC50swr_compile_gs(struct swr_context *ctx, swr_jit_gs_key &key);5152PFN_TCS_FUNC53swr_compile_tcs(struct swr_context *ctx, swr_jit_tcs_key &key);5455PFN_TES_FUNC56swr_compile_tes(struct swr_context *ctx, swr_jit_tes_key &key);5758void swr_generate_fs_key(struct swr_jit_fs_key &key,59struct swr_context *ctx,60swr_fragment_shader *swr_fs);6162void swr_generate_vs_key(struct swr_jit_vs_key &key,63struct swr_context *ctx,64swr_vertex_shader *swr_vs);6566void swr_generate_fetch_key(struct swr_jit_fetch_key &key,67struct swr_vertex_element_state *velems);6869void swr_generate_gs_key(struct swr_jit_gs_key &key,70struct swr_context *ctx,71swr_geometry_shader *swr_gs);7273void swr_generate_tcs_key(struct swr_jit_tcs_key &key,74struct swr_context *ctx,75swr_tess_control_shader *swr_tcs);7677void swr_generate_tes_key(struct swr_jit_tes_key &key,78struct swr_context *ctx,79swr_tess_evaluation_shader *swr_tes);8081struct swr_jit_sampler_key {82unsigned nr_samplers;83unsigned nr_sampler_views;84struct swr_sampler_static_state sampler[PIPE_MAX_SHADER_SAMPLER_VIEWS];85};8687struct swr_jit_fs_key : swr_jit_sampler_key {88unsigned nr_cbufs;89unsigned light_twoside;90unsigned sprite_coord_enable;91ubyte vs_output_semantic_name[PIPE_MAX_SHADER_OUTPUTS];92ubyte vs_output_semantic_idx[PIPE_MAX_SHADER_OUTPUTS];93bool poly_stipple_enable;94};9596struct swr_jit_vs_key : swr_jit_sampler_key {97unsigned clip_plane_mask; // from rasterizer state & vs_info98};99100struct swr_jit_fetch_key {101FETCH_COMPILE_STATE fsState;102};103104struct swr_jit_gs_key : swr_jit_sampler_key {105ubyte vs_output_semantic_name[PIPE_MAX_SHADER_OUTPUTS];106ubyte vs_output_semantic_idx[PIPE_MAX_SHADER_OUTPUTS];107};108109// TESS_TODO: revisit this - we probably need to use110// primitive modes, number of vertices emitted, etc.111struct swr_jit_tcs_key : swr_jit_sampler_key {112ubyte vs_output_semantic_name[PIPE_MAX_SHADER_OUTPUTS];113ubyte vs_output_semantic_idx[PIPE_MAX_SHADER_OUTPUTS];114unsigned clip_plane_mask; // from rasterizer state & tcs_info115};116117// TESS_TODO: revisit this118struct swr_jit_tes_key : swr_jit_sampler_key {119ubyte prev_output_semantic_name[PIPE_MAX_SHADER_OUTPUTS];120ubyte prev_output_semantic_idx[PIPE_MAX_SHADER_OUTPUTS];121unsigned clip_plane_mask; // from rasterizer state & tes_info122};123124namespace std125{126template <> struct hash<swr_jit_fs_key> {127std::size_t operator()(const swr_jit_fs_key &k) const128{129return util_hash_crc32(&k, sizeof(k));130}131};132133template <> struct hash<swr_jit_vs_key> {134std::size_t operator()(const swr_jit_vs_key &k) const135{136return util_hash_crc32(&k, sizeof(k));137}138};139140template <> struct hash<swr_jit_fetch_key> {141std::size_t operator()(const swr_jit_fetch_key &k) const142{143return util_hash_crc32(&k, sizeof(k));144}145};146147template <> struct hash<swr_jit_gs_key> {148std::size_t operator()(const swr_jit_gs_key &k) const149{150return util_hash_crc32(&k, sizeof(k));151}152};153154template <> struct hash<swr_jit_tcs_key> {155std::size_t operator()(const swr_jit_tcs_key &k) const156{157return util_hash_crc32(&k, sizeof(k));158}159};160161template <> struct hash<swr_jit_tes_key> {162std::size_t operator()(const swr_jit_tes_key &k) const163{164return util_hash_crc32(&k, sizeof(k));165}166};167};168169bool operator==(const swr_jit_fs_key &lhs, const swr_jit_fs_key &rhs);170bool operator==(const swr_jit_vs_key &lhs, const swr_jit_vs_key &rhs);171bool operator==(const swr_jit_fetch_key &lhs, const swr_jit_fetch_key &rhs);172bool operator==(const swr_jit_gs_key &lhs, const swr_jit_gs_key &rhs);173bool operator==(const swr_jit_tcs_key &lhs, const swr_jit_tcs_key &rhs);174bool operator==(const swr_jit_tes_key &lhs, const swr_jit_tes_key &rhs);175176177