1bf215546Sopenharmony_ci/************************************************************************** 2bf215546Sopenharmony_ci * 3bf215546Sopenharmony_ci * Copyright 2010-2012 VMware, Inc. 4bf215546Sopenharmony_ci * All Rights Reserved. 5bf215546Sopenharmony_ci * 6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the 8bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 9bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 10bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to 11bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 12bf215546Sopenharmony_ci * the following conditions: 13bf215546Sopenharmony_ci * 14bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 17bf215546Sopenharmony_ci * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 18bf215546Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19bf215546Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20bf215546Sopenharmony_ci * USE OR OTHER DEALINGS IN THE SOFTWARE. 21bf215546Sopenharmony_ci * 22bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the 23bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions 24bf215546Sopenharmony_ci * of the Software. 25bf215546Sopenharmony_ci * 26bf215546Sopenharmony_ci **************************************************************************/ 27bf215546Sopenharmony_ci 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#ifndef LP_BLD_LIMITS_H_ 30bf215546Sopenharmony_ci#define LP_BLD_LIMITS_H_ 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ci 33bf215546Sopenharmony_ci#include <limits.h> 34bf215546Sopenharmony_ci 35bf215546Sopenharmony_ci#include "pipe/p_state.h" 36bf215546Sopenharmony_ci#include "pipe/p_defines.h" 37bf215546Sopenharmony_ci#include "util/u_cpu_detect.h" 38bf215546Sopenharmony_ci 39bf215546Sopenharmony_ci/* 40bf215546Sopenharmony_ci * TGSI translation limits. 41bf215546Sopenharmony_ci * 42bf215546Sopenharmony_ci * Some are slightly above SM 3.0 requirements to give some wiggle room to 43bf215546Sopenharmony_ci * the gallium frontends. 44bf215546Sopenharmony_ci */ 45bf215546Sopenharmony_ci 46bf215546Sopenharmony_ci#define LP_MAX_TGSI_TEMPS 4096 47bf215546Sopenharmony_ci 48bf215546Sopenharmony_ci#define LP_MAX_TGSI_ADDRS 16 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_ci#define LP_MAX_TGSI_IMMEDIATES 4096 51bf215546Sopenharmony_ci 52bf215546Sopenharmony_ci#define LP_MAX_TGSI_CONSTS 4096 53bf215546Sopenharmony_ci 54bf215546Sopenharmony_ci#define LP_MAX_TGSI_CONST_BUFFERS 16 55bf215546Sopenharmony_ci 56bf215546Sopenharmony_ci#define LP_MAX_TGSI_CONST_BUFFER_SIZE (LP_MAX_TGSI_CONSTS * sizeof(float[4])) 57bf215546Sopenharmony_ci 58bf215546Sopenharmony_ci#define LP_MAX_TGSI_SHADER_BUFFERS 16 59bf215546Sopenharmony_ci 60bf215546Sopenharmony_ci#define LP_MAX_TGSI_SHADER_BUFFER_SIZE (1 << 27) 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_ci#define LP_MAX_TGSI_SHADER_IMAGES 32 63bf215546Sopenharmony_ci 64bf215546Sopenharmony_ci/* 65bf215546Sopenharmony_ci * For quick access we cache registers in statically 66bf215546Sopenharmony_ci * allocated arrays. Here we define the maximum size 67bf215546Sopenharmony_ci * for those arrays. 68bf215546Sopenharmony_ci */ 69bf215546Sopenharmony_ci#define LP_MAX_INLINED_TEMPS 256 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_ci#define LP_MAX_INLINED_IMMEDIATES 256 72bf215546Sopenharmony_ci 73bf215546Sopenharmony_ci/** 74bf215546Sopenharmony_ci * Maximum control flow nesting 75bf215546Sopenharmony_ci * 76bf215546Sopenharmony_ci * Vulkan CTS tests seem to have up to 76 levels. Add a few for safety. 77bf215546Sopenharmony_ci * SM4.0 requires 64 (per subroutine actually, subroutine nesting itself is 32) 78bf215546Sopenharmony_ci * SM3.0 requires 24 (most likely per subroutine too) 79bf215546Sopenharmony_ci * add 2 more (some translation could add one more) 80bf215546Sopenharmony_ci */ 81bf215546Sopenharmony_ci#define LP_MAX_TGSI_NESTING 80 82bf215546Sopenharmony_ci 83bf215546Sopenharmony_ci/** 84bf215546Sopenharmony_ci * Maximum iterations before loop termination 85bf215546Sopenharmony_ci * Shared between every loop in a TGSI shader 86bf215546Sopenharmony_ci */ 87bf215546Sopenharmony_ci#define LP_MAX_TGSI_LOOP_ITERATIONS 65535 88bf215546Sopenharmony_ci 89bf215546Sopenharmony_cistatic inline bool 90bf215546Sopenharmony_cilp_has_fp16(void) 91bf215546Sopenharmony_ci{ 92bf215546Sopenharmony_ci return util_get_cpu_caps()->has_f16c; 93bf215546Sopenharmony_ci} 94bf215546Sopenharmony_ci 95bf215546Sopenharmony_ci/** 96bf215546Sopenharmony_ci * Some of these limits are actually infinite (i.e., only limited by available 97bf215546Sopenharmony_ci * memory), however advertising INT_MAX would cause some test problems to 98bf215546Sopenharmony_ci * actually try to allocate the maximum and run out of memory and crash. So 99bf215546Sopenharmony_ci * stick with something reasonable here. 100bf215546Sopenharmony_ci */ 101bf215546Sopenharmony_cistatic inline int 102bf215546Sopenharmony_cigallivm_get_shader_param(enum pipe_shader_cap param) 103bf215546Sopenharmony_ci{ 104bf215546Sopenharmony_ci switch(param) { 105bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_INSTRUCTIONS: 106bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS: 107bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS: 108bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS: 109bf215546Sopenharmony_ci return 1 * 1024 * 1024; 110bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH: 111bf215546Sopenharmony_ci return LP_MAX_TGSI_NESTING; 112bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_INPUTS: 113bf215546Sopenharmony_ci return 32; 114bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_OUTPUTS: 115bf215546Sopenharmony_ci return 32; 116bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_CONST_BUFFER0_SIZE: 117bf215546Sopenharmony_ci return LP_MAX_TGSI_CONST_BUFFER_SIZE; 118bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_CONST_BUFFERS: 119bf215546Sopenharmony_ci return LP_MAX_TGSI_CONST_BUFFERS; 120bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEMPS: 121bf215546Sopenharmony_ci return LP_MAX_TGSI_TEMPS; 122bf215546Sopenharmony_ci case PIPE_SHADER_CAP_CONT_SUPPORTED: 123bf215546Sopenharmony_ci return 1; 124bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR: 125bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR: 126bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR: 127bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR: 128bf215546Sopenharmony_ci return 1; 129bf215546Sopenharmony_ci case PIPE_SHADER_CAP_SUBROUTINES: 130bf215546Sopenharmony_ci return 1; 131bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INTEGERS: 132bf215546Sopenharmony_ci return 1; 133bf215546Sopenharmony_ci case PIPE_SHADER_CAP_FP16: 134bf215546Sopenharmony_ci case PIPE_SHADER_CAP_FP16_DERIVATIVES: 135bf215546Sopenharmony_ci return lp_has_fp16(); 136bf215546Sopenharmony_ci //enabling this breaks GTF-GL46.gtf21.GL2Tests.glGetUniform.glGetUniform 137bf215546Sopenharmony_ci case PIPE_SHADER_CAP_FP16_CONST_BUFFERS: 138bf215546Sopenharmony_ci return 0; 139bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INT64_ATOMICS: 140bf215546Sopenharmony_ci return 0; 141bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INT16: 142bf215546Sopenharmony_ci case PIPE_SHADER_CAP_GLSL_16BIT_CONSTS: 143bf215546Sopenharmony_ci return 1; 144bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: 145bf215546Sopenharmony_ci return PIPE_MAX_SAMPLERS; 146bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS: 147bf215546Sopenharmony_ci return PIPE_MAX_SHADER_SAMPLER_VIEWS; 148bf215546Sopenharmony_ci case PIPE_SHADER_CAP_PREFERRED_IR: 149bf215546Sopenharmony_ci return PIPE_SHADER_IR_TGSI; 150bf215546Sopenharmony_ci case PIPE_SHADER_CAP_SUPPORTED_IRS: 151bf215546Sopenharmony_ci return (1 << PIPE_SHADER_IR_TGSI) | (1 << PIPE_SHADER_IR_NIR); 152bf215546Sopenharmony_ci case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED: 153bf215546Sopenharmony_ci case PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE: 154bf215546Sopenharmony_ci return 1; 155bf215546Sopenharmony_ci case PIPE_SHADER_CAP_DROUND_SUPPORTED: 156bf215546Sopenharmony_ci case PIPE_SHADER_CAP_DFRACEXP_DLDEXP_SUPPORTED: 157bf215546Sopenharmony_ci case PIPE_SHADER_CAP_LDEXP_SUPPORTED: 158bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS: 159bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER_BUFFERS: 160bf215546Sopenharmony_ci return 0; 161bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_SHADER_BUFFERS: 162bf215546Sopenharmony_ci return LP_MAX_TGSI_SHADER_BUFFERS; 163bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_SHADER_IMAGES: 164bf215546Sopenharmony_ci return LP_MAX_TGSI_SHADER_IMAGES; 165bf215546Sopenharmony_ci } 166bf215546Sopenharmony_ci /* if we get here, we missed a shader cap above (and should have seen 167bf215546Sopenharmony_ci * a compiler warning.) 168bf215546Sopenharmony_ci */ 169bf215546Sopenharmony_ci return 0; 170bf215546Sopenharmony_ci} 171bf215546Sopenharmony_ci 172bf215546Sopenharmony_ci 173bf215546Sopenharmony_ci#endif /* LP_BLD_LIMITS_H_ */ 174