[Mesa-dev] [PATCH 1/3] svga: added svga_shader_too_large() helper

Brian Paul brianp at vmware.com
Thu May 29 13:59:57 PDT 2014


To check if a shader bytcode exceeds the device limit.  There's no
limit when using GBS.
---
 src/gallium/drivers/svga/svga_shader.h |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/gallium/drivers/svga/svga_shader.h b/src/gallium/drivers/svga/svga_shader.h
index 348dc0c..fd500ae 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 */
-- 
1.7.10.4



More information about the mesa-dev mailing list