=?UTF-8?Q?Rico=20Sch=C3=BCller=20?=: d3dx9: Improve is_valid_constant().
Alexandre Julliard
julliard at winehq.org
Fri Aug 24 13:46:43 CDT 2012
Module: wine
Branch: master
Commit: 12788436430dcf5ba6a89f0505be16c016abf52d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=12788436430dcf5ba6a89f0505be16c016abf52d
Author: Rico Schüller <kgbricola at web.de>
Date: Thu Aug 23 21:36:58 2012 +0200
d3dx9: Improve is_valid_constant().
---
dlls/d3dx9_36/shader.c | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/dlls/d3dx9_36/shader.c b/dlls/d3dx9_36/shader.c
index 69bb40e..c761aef 100644
--- a/dlls/d3dx9_36/shader.c
+++ b/dlls/d3dx9_36/shader.c
@@ -690,6 +690,28 @@ static inline D3DXHANDLE handle_from_constant(struct ctab_constant *constant)
return (D3DXHANDLE)constant;
}
+static struct ctab_constant *is_valid_sub_constant(struct ctab_constant *parent, struct ctab_constant *constant)
+{
+ UINT i, count;
+
+ /* all variable have at least elements = 1, but no elements */
+ if (!parent->constants) return NULL;
+
+ if (parent->desc.Elements > 1) count = parent->desc.Elements;
+ else count = parent->desc.StructMembers;
+
+ for (i = 0; i < count; ++i)
+ {
+ if (&parent->constants[i] == constant)
+ return constant;
+
+ if (is_valid_sub_constant(&parent->constants[i], constant))
+ return constant;
+ }
+
+ return NULL;
+}
+
static inline struct ctab_constant *is_valid_constant(struct ID3DXConstantTableImpl *table, D3DXHANDLE handle)
{
struct ctab_constant *c = constant_from_handle(handle);
@@ -699,7 +721,11 @@ static inline struct ctab_constant *is_valid_constant(struct ID3DXConstantTableI
for (i = 0; i < table->desc.Constants; ++i)
{
- if (&table->constants[i] == c) return c;
+ if (&table->constants[i] == c)
+ return c;
+
+ if (is_valid_sub_constant(&table->constants[i], c))
+ return c;
}
return NULL;
More information about the wine-cvs
mailing list