From: Brian Paul Date: Thu, 29 May 2014 19:55:46 +0000 (-0600) Subject: svga: added svga_shader_too_large() helper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7b2ff544176c34cd3b0f5f10caa44e497ecab0ad;p=mesa.git svga: added svga_shader_too_large() helper To check if a shader bytcode exceeds the device limit. There's no limit when using GBS. Reviewed-by: José Fonseca --- diff --git a/src/gallium/drivers/svga/svga_shader.h b/src/gallium/drivers/svga/svga_shader.h index 348dc0c59e2..fd500ae4401 100644 --- a/src/gallium/drivers/svga/svga_shader.h +++ b/src/gallium/drivers/svga/svga_shader.h @@ -41,4 +41,25 @@ svga_destroy_shader_variant(struct svga_context *svga, struct svga_shader_variant *variant); +/** + * Check if a shader's bytecode exceeds the device limits. + */ +static INLINE boolean +svga_shader_too_large(const struct svga_context *svga, + const struct svga_shader_variant *variant) +{ + if (svga_have_gb_objects(svga)) { + return FALSE; + } + + if (variant->nr_tokens * sizeof(variant->tokens[0]) + + sizeof(SVGA3dCmdDefineShader) + sizeof(SVGA3dCmdHeader) + < SVGA_CB_MAX_COMMAND_SIZE) { + return FALSE; + } + + return TRUE; +} + + #endif /* SVGA_SHADER_H */