*
*/
+#include "config.h"
+#include "wine/port.h"
+
+#include <stdio.h>
+
#include "d3dcompiler_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3dcompiler);
return S_OK;
}
-HRESULT dxbc_init(struct dxbc *dxbc, UINT size)
+HRESULT dxbc_init(struct dxbc *dxbc, unsigned int size)
{
TRACE("dxbc %p, size %u.\n", dxbc, size);
static enum hlsl_base_type expr_common_base_type(enum hlsl_base_type t1, enum hlsl_base_type t2)
{
- enum hlsl_base_type types[] =
+ static const enum hlsl_base_type types[] =
{
HLSL_TYPE_BOOL,
HLSL_TYPE_INT,
};
int t1_idx = -1, t2_idx = -1, i;
- for (i = 0; i < sizeof(types) / sizeof(types[0]); ++i)
+ for (i = 0; i < ARRAY_SIZE(types); ++i)
{
/* Always convert away from HLSL_TYPE_HALF */
if (t1 == types[i])
return strcmp(name, type->name);
}
-static inline void *d3dcompiler_alloc_rb(size_t size)
-{
- return d3dcompiler_alloc(size);
-}
-
-static inline void *d3dcompiler_realloc_rb(void *ptr, size_t size)
-{
- return d3dcompiler_realloc(ptr, size);
-}
-
-static inline void d3dcompiler_free_rb(void *ptr)
-{
- d3dcompiler_free(ptr);
-}
-static const struct wine_rb_functions hlsl_type_rb_funcs =
-{
- d3dcompiler_alloc_rb,
- d3dcompiler_realloc_rb,
- d3dcompiler_free_rb,
- compare_hlsl_types_rb,
-};
-
void push_scope(struct hlsl_parse_ctx *ctx)
{
struct hlsl_scope *new_scope = d3dcompiler_alloc(sizeof(*new_scope));
}
TRACE("Pushing a new scope\n");
list_init(&new_scope->vars);
- if (wine_rb_init(&new_scope->types, &hlsl_type_rb_funcs) == -1)
- {
- ERR("Failed to initialize types rbtree.\n");
- d3dcompiler_free(new_scope);
- return;
- }
+ wine_rb_init(&new_scope->types, compare_hlsl_types_rb);
new_scope->upper = ctx->cur_scope;
ctx->cur_scope = new_scope;
list_add_tail(&ctx->scopes, &new_scope->entry);
return 0;
}
-static const struct wine_rb_functions hlsl_ir_function_decl_rb_funcs =
-{
- d3dcompiler_alloc_rb,
- d3dcompiler_realloc_rb,
- d3dcompiler_free_rb,
- compare_function_decl_rb,
-};
-
static int compare_function_rb(const void *key, const struct wine_rb_entry *entry)
{
const char *name = key;
return strcmp(name, func->name);
}
-static const struct wine_rb_functions function_rb_funcs =
-{
- d3dcompiler_alloc_rb,
- d3dcompiler_realloc_rb,
- d3dcompiler_free_rb,
- compare_function_rb,
-};
-
void init_functions_tree(struct wine_rb_tree *funcs)
{
- if (wine_rb_init(&hlsl_ctx.functions, &function_rb_funcs) == -1)
- ERR("Failed to initialize functions rbtree.\n");
+ wine_rb_init(&hlsl_ctx.functions, compare_function_rb);
}
static const char *debug_base_type(const struct hlsl_type *type)
"HLSL_IR_SWIZZLE",
};
- if (type >= sizeof(names) / sizeof(names[0]))
+ if (type >= ARRAY_SIZE(names))
return "Unexpected node type";
return names[type];
}
TRACE("Function %s redeclared as a user defined function.\n", debugstr_a(name));
func->intrinsic = intrinsic;
wine_rb_destroy(&func->overloads, free_function_decl_rb, NULL);
- if (wine_rb_init(&func->overloads, &hlsl_ir_function_decl_rb_funcs) == -1)
- {
- ERR("Failed to initialize function rbtree.\n");
- return;
- }
+ wine_rb_init(&func->overloads, compare_function_decl_rb);
}
decl->func = func;
if ((old_entry = wine_rb_get(&func->overloads, decl->parameters)))
d3dcompiler_free(name);
return;
}
- wine_rb_remove(&func->overloads, decl->parameters);
+ wine_rb_remove(&func->overloads, old_entry);
free_function_decl(old_decl);
}
wine_rb_put(&func->overloads, decl->parameters, &decl->entry);
}
func = d3dcompiler_alloc(sizeof(*func));
func->name = name;
- if (wine_rb_init(&func->overloads, &hlsl_ir_function_decl_rb_funcs) == -1)
- {
- ERR("Failed to initialize function rbtree.\n");
- d3dcompiler_free(name);
- d3dcompiler_free(func);
- return;
- }
+ wine_rb_init(&func->overloads, compare_function_decl_rb);
decl->func = func;
wine_rb_put(&func->overloads, decl->parameters, &decl->entry);
func->intrinsic = intrinsic;