From a508d2dddcc67d0f92cc36b9ed6f36a9bbfc579d Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Sun, 5 Sep 2010 20:50:50 +0200 Subject: gallium: introduce get_shader_param (ALL DRIVERS CHANGED) (v3) Changes in v3: - Also change trace, which I forgot about Changes in v2: - No longer adds tessellation shaders Currently each shader cap has FS and VS versions. However, we want a version of them for geometry, tessellation control, and tessellation evaluation shaders, and want to be able to easily query a given cap type for a given shader stage. Since having 5 duplicates of each shader cap is unmanageable, add a new get_shader_param function that takes both a shader cap from a new enum and a shader stage. Drivers with non-unified shaders will first switch on the shader and, within each case, switch on the cap. Drivers with unified shaders instead first check whether the shader is supported, and then switch on the cap. MAX_CONST_BUFFERS is now per-stage. The geometry shader cap is removed in favor of checking whether the limit of geometry shader instructions is greater than 0, which is also used for tessellation shaders. WARNING: all drivers changed and compiled but only nvfx tested --- src/gallium/drivers/r300/r300_screen.c | 96 +++++++++++++++++++++------------- 1 file changed, 61 insertions(+), 35 deletions(-) (limited to 'src/gallium/drivers/r300') diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 1e4edcdbc31..7f41ff0e2ec 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -120,7 +120,6 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param) /* Unsupported features (boolean caps). */ case PIPE_CAP_TIMER_QUERY: case PIPE_CAP_DUAL_SOURCE_BLEND: - case PIPE_CAP_TGSI_CONT_SUPPORTED: case PIPE_CAP_INDEP_BLEND_ENABLE: case PIPE_CAP_INDEP_BLEND_FUNC: case PIPE_CAP_DEPTH_CLAMP: /* XXX implemented, but breaks Regnum Online */ @@ -146,11 +145,6 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param) /* General shader limits and features. */ case PIPE_CAP_SM3: return is_r500 ? 1 : 0; - case PIPE_CAP_MAX_CONST_BUFFERS: - return 1; - case PIPE_CAP_MAX_CONST_BUFFER_SIZE: - return 256; - /* Fragment coordinate conventions. */ case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: @@ -158,19 +152,39 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param) case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: return 0; + default: + fprintf(stderr, "r300: Implementation error: Bad param %d\n", + param); + return 0; + } +} - /* Fragment shader limits. */ - case PIPE_CAP_MAX_FS_INSTRUCTIONS: +static int r300_get_shader_param(struct pipe_screen *pscreen, unsigned shader, enum pipe_shader_cap param) +{ + struct r300_screen* r300screen = r300_screen(pscreen); + boolean is_r400 = r300screen->caps.is_r400; + boolean is_r500 = r300screen->caps.is_r500; + + /* XXX extended shader capabilities of r400 unimplemented */ + is_r400 = FALSE; + + switch (shader) + { + case PIPE_SHADER_FRAGMENT: + switch (param) + { + case PIPE_SHADER_CAP_MAX_INSTRUCTIONS: return is_r500 || is_r400 ? 512 : 96; - case PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS: + case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS: return is_r500 || is_r400 ? 512 : 64; - case PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS: + case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS: return is_r500 || is_r400 ? 512 : 32; - case PIPE_CAP_MAX_FS_TEX_INDIRECTIONS: + case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS: return is_r500 ? 511 : 4; - case PIPE_CAP_MAX_FS_CONTROL_FLOW_DEPTH: + case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH: return is_r500 ? 64 : 0; /* Actually unlimited on r500. */ - case PIPE_CAP_MAX_FS_INPUTS: + /* Fragment shader limits. */ + case PIPE_SHADER_CAP_MAX_INPUTS: /* 2 colors + 8 texcoords are always supported * (minus fog and wpos). * @@ -178,42 +192,53 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param) * additional texcoords but there is no two-sided color * selection then. However the facing bit can be used instead. */ return 10; - case PIPE_CAP_MAX_FS_CONSTS: + case PIPE_SHADER_CAP_MAX_CONSTS: return is_r500 ? 256 : 32; - case PIPE_CAP_MAX_FS_TEMPS: + case PIPE_SHADER_CAP_MAX_CONST_BUFFERS: + return 1; + case PIPE_SHADER_CAP_MAX_TEMPS: return is_r500 ? 128 : is_r400 ? 64 : 32; - case PIPE_CAP_MAX_FS_ADDRS: + case PIPE_SHADER_CAP_MAX_ADDRS: return 0; - case PIPE_CAP_MAX_FS_PREDS: + case PIPE_SHADER_CAP_MAX_PREDS: return is_r500 ? 1 : 0; - - /* Vertex shader limits. */ - case PIPE_CAP_MAX_VS_INSTRUCTIONS: - case PIPE_CAP_MAX_VS_ALU_INSTRUCTIONS: + case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED: + return 1; + } + break; + case PIPE_SHADER_VERTEX: + switch (param) + { + case PIPE_SHADER_CAP_MAX_INSTRUCTIONS: + case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS: return is_r500 ? 1024 : 256; - case PIPE_CAP_MAX_VS_TEX_INSTRUCTIONS: - case PIPE_CAP_MAX_VS_TEX_INDIRECTIONS: + case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS: + case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS: return 0; - case PIPE_CAP_MAX_VS_CONTROL_FLOW_DEPTH: + case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH: return is_r500 ? 4 : 0; /* For loops; not sure about conditionals. */ - case PIPE_CAP_MAX_VS_INPUTS: + case PIPE_SHADER_CAP_MAX_INPUTS: return 16; - case PIPE_CAP_MAX_VS_CONSTS: + case PIPE_SHADER_CAP_MAX_CONSTS: return 256; - case PIPE_CAP_MAX_VS_TEMPS: + case PIPE_SHADER_CAP_MAX_CONST_BUFFERS: + return 1; + case PIPE_SHADER_CAP_MAX_TEMPS: return 32; - case PIPE_CAP_MAX_VS_ADDRS: + case PIPE_SHADER_CAP_MAX_ADDRS: return 1; /* XXX guessed */ - case PIPE_CAP_MAX_VS_PREDS: + case PIPE_SHADER_CAP_MAX_PREDS: return is_r500 ? 4 : 0; /* XXX guessed. */ - case PIPE_CAP_GEOMETRY_SHADER4: - return 0; - + case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED: + return 1; default: - fprintf(stderr, "r300: Implementation error: Bad param %d\n", - param); - return 0; + break; + } + break; + default: + break; } + return 0; } static float r300_get_paramf(struct pipe_screen* pscreen, enum pipe_cap param) @@ -410,6 +435,7 @@ struct pipe_screen* r300_screen_create(struct r300_winsys_screen *rws) r300screen->screen.get_name = r300_get_name; r300screen->screen.get_vendor = r300_get_vendor; r300screen->screen.get_param = r300_get_param; + r300screen->screen.get_shader_param = r300_get_shader_param; r300screen->screen.get_paramf = r300_get_paramf; r300screen->screen.is_format_supported = r300_is_format_supported; r300screen->screen.context_create = r300_create_context; -- cgit v1.2.3