2010-10-03 15:11:54 +02:00
|
|
|
/*
|
2010-10-18 13:05:50 +02:00
|
|
|
* Copyright 2008 Stefan Dösinger
|
|
|
|
* Copyright 2009 Matteo Bruni
|
2010-10-03 15:11:54 +02:00
|
|
|
* Copyright 2008-2009 Henri Verbeet for CodeWeavers
|
|
|
|
* Copyright 2010 Rico Schüller
|
2012-06-04 17:58:23 +02:00
|
|
|
* Copyright 2012 Matteo Bruni for CodeWeavers
|
2010-10-03 15:11:54 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-05-08 16:17:31 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2010-10-03 15:11:54 +02:00
|
|
|
#include "d3dcompiler_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3dcompiler);
|
|
|
|
|
|
|
|
#define WINE_D3DCOMPILER_TO_STR(x) case x: return #x
|
|
|
|
|
2011-03-03 21:44:00 +01:00
|
|
|
const char *debug_d3dcompiler_shader_variable_class(D3D_SHADER_VARIABLE_CLASS c)
|
|
|
|
{
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVC_SCALAR);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVC_VECTOR);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVC_MATRIX_ROWS);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVC_MATRIX_COLUMNS);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVC_OBJECT);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVC_STRUCT);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVC_INTERFACE_CLASS);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVC_INTERFACE_POINTER);
|
|
|
|
default:
|
|
|
|
FIXME("Unrecognized D3D_SHADER_VARIABLE_CLASS %#x.\n", c);
|
|
|
|
return "unrecognized";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-03 21:44:02 +01:00
|
|
|
const char *debug_d3dcompiler_shader_variable_type(D3D_SHADER_VARIABLE_TYPE t)
|
|
|
|
{
|
|
|
|
switch (t)
|
|
|
|
{
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_VOID);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_BOOL);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_INT);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_FLOAT);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_STRING);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_TEXTURE);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_TEXTURE1D);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_TEXTURE2D);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_TEXTURE3D);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_TEXTURECUBE);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_SAMPLER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_PIXELSHADER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_VERTEXSHADER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_UINT);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_UINT8);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_GEOMETRYSHADER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_RASTERIZER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_DEPTHSTENCIL);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_BLEND);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_BUFFER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_CBUFFER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_TBUFFER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_TEXTURE1DARRAY);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_TEXTURE2DARRAY);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_RENDERTARGETVIEW);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_DEPTHSTENCILVIEW);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_TEXTURE2DMS);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_TEXTURE2DMSARRAY);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_TEXTURECUBEARRAY);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_HULLSHADER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_DOMAINSHADER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_INTERFACE_POINTER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_COMPUTESHADER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_DOUBLE);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_RWTEXTURE1D);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_RWTEXTURE1DARRAY);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_RWTEXTURE2D);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_RWTEXTURE2DARRAY);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_RWTEXTURE3D);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_RWBUFFER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_BYTEADDRESS_BUFFER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_RWBYTEADDRESS_BUFFER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_STRUCTURED_BUFFER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_RWSTRUCTURED_BUFFER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_APPEND_STRUCTURED_BUFFER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_SVT_CONSUME_STRUCTURED_BUFFER);
|
|
|
|
default:
|
|
|
|
FIXME("Unrecognized D3D_SHADER_VARIABLE_TYPE %#x.\n", t);
|
|
|
|
return "unrecognized";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-03 15:11:54 +02:00
|
|
|
const char *debug_d3dcompiler_d3d_blob_part(D3D_BLOB_PART part)
|
|
|
|
{
|
|
|
|
switch(part)
|
|
|
|
{
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_BLOB_INPUT_SIGNATURE_BLOB);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_BLOB_OUTPUT_SIGNATURE_BLOB);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_BLOB_ALL_SIGNATURE_BLOB);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_BLOB_DEBUG_INFO);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_BLOB_LEGACY_SHADER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_BLOB_XNA_PREPASS_SHADER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_BLOB_XNA_SHADER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_BLOB_TEST_ALTERNATE_SHADER);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_BLOB_TEST_COMPILE_DETAILS);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(D3D_BLOB_TEST_COMPILE_PERF);
|
|
|
|
default:
|
|
|
|
FIXME("Unrecognized D3D_BLOB_PART %#x\n", part);
|
|
|
|
return "unrecognized";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:30:05 +01:00
|
|
|
const char *debug_print_srcmod(uint32_t mod)
|
2010-10-18 13:05:50 +02:00
|
|
|
{
|
|
|
|
switch (mod)
|
|
|
|
{
|
|
|
|
WINE_D3DCOMPILER_TO_STR(BWRITERSPSM_NEG);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(BWRITERSPSM_BIAS);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(BWRITERSPSM_BIASNEG);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(BWRITERSPSM_SIGN);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(BWRITERSPSM_SIGNNEG);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(BWRITERSPSM_COMP);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(BWRITERSPSM_X2);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(BWRITERSPSM_X2NEG);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(BWRITERSPSM_DZ);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(BWRITERSPSM_DW);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(BWRITERSPSM_ABS);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(BWRITERSPSM_ABSNEG);
|
|
|
|
WINE_D3DCOMPILER_TO_STR(BWRITERSPSM_NOT);
|
|
|
|
default:
|
2022-02-09 16:30:05 +01:00
|
|
|
FIXME("Unrecognized source modifier %#x.\n", mod);
|
2010-10-18 13:05:50 +02:00
|
|
|
return "unrecognized_src_mod";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-03 15:11:54 +02:00
|
|
|
#undef WINE_D3DCOMPILER_TO_STR
|
|
|
|
|
2022-02-09 16:30:05 +01:00
|
|
|
const char *debug_print_dstmod(uint32_t mod)
|
2010-10-18 13:05:50 +02:00
|
|
|
{
|
|
|
|
switch (mod)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return "";
|
|
|
|
case BWRITERSPDM_SATURATE:
|
|
|
|
return "_sat";
|
|
|
|
case BWRITERSPDM_PARTIALPRECISION:
|
|
|
|
return "_pp";
|
|
|
|
case BWRITERSPDM_MSAMPCENTROID:
|
|
|
|
return "_centroid";
|
|
|
|
case BWRITERSPDM_SATURATE | BWRITERSPDM_PARTIALPRECISION:
|
|
|
|
return "_sat_pp";
|
|
|
|
case BWRITERSPDM_SATURATE | BWRITERSPDM_MSAMPCENTROID:
|
|
|
|
return "_sat_centroid";
|
|
|
|
case BWRITERSPDM_PARTIALPRECISION | BWRITERSPDM_MSAMPCENTROID:
|
|
|
|
return "_pp_centroid";
|
|
|
|
case BWRITERSPDM_SATURATE | BWRITERSPDM_PARTIALPRECISION | BWRITERSPDM_MSAMPCENTROID:
|
|
|
|
return "_sat_pp_centroid";
|
|
|
|
default:
|
|
|
|
return "Unexpected modifier\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:30:05 +01:00
|
|
|
const char *debug_print_shift(uint32_t shift)
|
2010-10-18 13:05:50 +02:00
|
|
|
{
|
|
|
|
static const char * const shiftstrings[] =
|
|
|
|
{
|
|
|
|
"",
|
|
|
|
"_x2",
|
|
|
|
"_x4",
|
|
|
|
"_x8",
|
|
|
|
"_x16",
|
|
|
|
"_x32",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"_d16",
|
|
|
|
"_d8",
|
|
|
|
"_d4",
|
|
|
|
"_d2",
|
|
|
|
};
|
|
|
|
return shiftstrings[shift];
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *get_regname(const struct shader_reg *reg)
|
|
|
|
{
|
|
|
|
switch (reg->type)
|
|
|
|
{
|
|
|
|
case BWRITERSPR_TEMP:
|
2022-02-09 16:30:05 +01:00
|
|
|
return wine_dbg_sprintf("r%u", reg->regnum);
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPR_INPUT:
|
2022-02-09 16:30:05 +01:00
|
|
|
return wine_dbg_sprintf("v%u", reg->regnum);
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPR_CONST:
|
2022-02-09 16:30:05 +01:00
|
|
|
return wine_dbg_sprintf("c%u", reg->regnum);
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPR_ADDR:
|
2022-02-09 16:30:05 +01:00
|
|
|
return wine_dbg_sprintf("a%u", reg->regnum);
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPR_TEXTURE:
|
2022-02-09 16:30:05 +01:00
|
|
|
return wine_dbg_sprintf("t%u", reg->regnum);
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPR_RASTOUT:
|
|
|
|
switch (reg->regnum)
|
|
|
|
{
|
|
|
|
case BWRITERSRO_POSITION: return "oPos";
|
|
|
|
case BWRITERSRO_FOG: return "oFog";
|
|
|
|
case BWRITERSRO_POINT_SIZE: return "oPts";
|
|
|
|
default: return "Unexpected RASTOUT";
|
|
|
|
}
|
|
|
|
case BWRITERSPR_ATTROUT:
|
2022-02-09 16:30:05 +01:00
|
|
|
return wine_dbg_sprintf("oD%u", reg->regnum);
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPR_TEXCRDOUT:
|
2022-02-09 16:30:05 +01:00
|
|
|
return wine_dbg_sprintf("oT%u", reg->regnum);
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPR_OUTPUT:
|
2022-02-09 16:30:05 +01:00
|
|
|
return wine_dbg_sprintf("o%u", reg->regnum);
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPR_CONSTINT:
|
2022-02-09 16:30:05 +01:00
|
|
|
return wine_dbg_sprintf("i%u", reg->regnum);
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPR_COLOROUT:
|
2022-02-09 16:30:05 +01:00
|
|
|
return wine_dbg_sprintf("oC%u", reg->regnum);
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPR_DEPTHOUT:
|
|
|
|
return "oDepth";
|
|
|
|
case BWRITERSPR_SAMPLER:
|
2022-02-09 16:30:05 +01:00
|
|
|
return wine_dbg_sprintf("s%u", reg->regnum);
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPR_CONSTBOOL:
|
2022-02-09 16:30:05 +01:00
|
|
|
return wine_dbg_sprintf("b%u", reg->regnum);
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPR_LOOP:
|
|
|
|
return "aL";
|
|
|
|
case BWRITERSPR_MISCTYPE:
|
|
|
|
switch (reg->regnum)
|
|
|
|
{
|
|
|
|
case 0: return "vPos";
|
|
|
|
case 1: return "vFace";
|
2011-02-23 18:05:12 +01:00
|
|
|
default: return "unexpected misctype";
|
2010-10-18 13:05:50 +02:00
|
|
|
}
|
|
|
|
case BWRITERSPR_LABEL:
|
2022-02-09 16:30:05 +01:00
|
|
|
return wine_dbg_sprintf("l%u", reg->regnum);
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPR_PREDICATE:
|
2022-02-09 16:30:05 +01:00
|
|
|
return wine_dbg_sprintf("p%u", reg->regnum);
|
2010-10-18 13:05:50 +02:00
|
|
|
default:
|
2022-02-09 16:30:05 +01:00
|
|
|
return wine_dbg_sprintf("unknown regname %#x", reg->type);
|
2010-10-18 13:05:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:30:05 +01:00
|
|
|
static const char *debug_print_writemask(uint32_t mask)
|
2010-10-18 13:05:50 +02:00
|
|
|
{
|
|
|
|
char ret[6];
|
|
|
|
unsigned char pos = 1;
|
|
|
|
|
|
|
|
if(mask == BWRITERSP_WRITEMASK_ALL) return "";
|
|
|
|
ret[0] = '.';
|
|
|
|
if(mask & BWRITERSP_WRITEMASK_0) ret[pos++] = 'x';
|
|
|
|
if(mask & BWRITERSP_WRITEMASK_1) ret[pos++] = 'y';
|
|
|
|
if(mask & BWRITERSP_WRITEMASK_2) ret[pos++] = 'z';
|
|
|
|
if(mask & BWRITERSP_WRITEMASK_3) ret[pos++] = 'w';
|
|
|
|
ret[pos] = 0;
|
|
|
|
|
|
|
|
return wine_dbg_sprintf("%s", ret);
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:30:05 +01:00
|
|
|
static const char *debug_print_swizzle(uint32_t arg)
|
2010-10-18 13:05:50 +02:00
|
|
|
{
|
|
|
|
char ret[6];
|
|
|
|
unsigned int i;
|
2022-02-09 16:30:05 +01:00
|
|
|
uint32_t swizzle[4];
|
2010-10-18 13:05:50 +02:00
|
|
|
|
|
|
|
switch (arg)
|
|
|
|
{
|
|
|
|
case BWRITERVS_NOSWIZZLE:
|
|
|
|
return "";
|
|
|
|
case BWRITERVS_SWIZZLE_X:
|
|
|
|
return ".x";
|
|
|
|
case BWRITERVS_SWIZZLE_Y:
|
|
|
|
return ".y";
|
|
|
|
case BWRITERVS_SWIZZLE_Z:
|
|
|
|
return ".z";
|
|
|
|
case BWRITERVS_SWIZZLE_W:
|
|
|
|
return ".w";
|
|
|
|
}
|
|
|
|
|
2020-02-05 21:52:32 +01:00
|
|
|
swizzle[0] = arg & 3;
|
|
|
|
swizzle[1] = (arg >> 2) & 3;
|
|
|
|
swizzle[2] = (arg >> 4) & 3;
|
|
|
|
swizzle[3] = (arg >> 6) & 3;
|
2010-10-18 13:05:50 +02:00
|
|
|
|
|
|
|
ret[0] = '.';
|
|
|
|
for (i = 0; i < 4; ++i)
|
|
|
|
{
|
|
|
|
switch (swizzle[i])
|
|
|
|
{
|
|
|
|
case 0: ret[1 + i] = 'x'; break;
|
|
|
|
case 1: ret[1 + i] = 'y'; break;
|
|
|
|
case 2: ret[1 + i] = 'z'; break;
|
|
|
|
case 3: ret[1 + i] = 'w'; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret[5] = '\0';
|
|
|
|
|
|
|
|
return wine_dbg_sprintf("%s", ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *debug_print_relarg(const struct shader_reg *reg)
|
|
|
|
{
|
|
|
|
const char *short_swizzle;
|
|
|
|
if (!reg->rel_reg) return "";
|
|
|
|
|
2022-02-09 16:30:05 +01:00
|
|
|
short_swizzle = debug_print_swizzle(reg->rel_reg->swizzle);
|
2010-10-18 13:05:50 +02:00
|
|
|
|
|
|
|
if (reg->rel_reg->type == BWRITERSPR_ADDR)
|
2022-02-09 16:30:05 +01:00
|
|
|
return wine_dbg_sprintf("[a%u%s]", reg->rel_reg->regnum, short_swizzle);
|
2010-10-18 13:05:50 +02:00
|
|
|
else if(reg->rel_reg->type == BWRITERSPR_LOOP && reg->rel_reg->regnum == 0)
|
|
|
|
return wine_dbg_sprintf("[aL%s]", short_swizzle);
|
|
|
|
else
|
|
|
|
return "Unexpected relative addressing argument";
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *debug_print_dstreg(const struct shader_reg *reg)
|
|
|
|
{
|
|
|
|
return wine_dbg_sprintf("%s%s%s", get_regname(reg),
|
|
|
|
debug_print_relarg(reg),
|
2022-02-09 16:30:05 +01:00
|
|
|
debug_print_writemask(reg->writemask));
|
2010-10-18 13:05:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *debug_print_srcreg(const struct shader_reg *reg)
|
|
|
|
{
|
|
|
|
switch (reg->srcmod)
|
|
|
|
{
|
|
|
|
case BWRITERSPSM_NONE:
|
|
|
|
return wine_dbg_sprintf("%s%s%s", get_regname(reg),
|
|
|
|
debug_print_relarg(reg),
|
2022-02-09 16:30:05 +01:00
|
|
|
debug_print_swizzle(reg->swizzle));
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPSM_NEG:
|
|
|
|
return wine_dbg_sprintf("-%s%s%s", get_regname(reg),
|
|
|
|
debug_print_relarg(reg),
|
2022-02-09 16:30:05 +01:00
|
|
|
debug_print_swizzle(reg->swizzle));
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPSM_BIAS:
|
|
|
|
return wine_dbg_sprintf("%s%s_bias%s", get_regname(reg),
|
|
|
|
debug_print_relarg(reg),
|
2022-02-09 16:30:05 +01:00
|
|
|
debug_print_swizzle(reg->swizzle));
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPSM_BIASNEG:
|
|
|
|
return wine_dbg_sprintf("-%s%s_bias%s", get_regname(reg),
|
|
|
|
debug_print_relarg(reg),
|
2022-02-09 16:30:05 +01:00
|
|
|
debug_print_swizzle(reg->swizzle));
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPSM_SIGN:
|
|
|
|
return wine_dbg_sprintf("%s%s_bx2%s", get_regname(reg),
|
|
|
|
debug_print_relarg(reg),
|
2022-02-09 16:30:05 +01:00
|
|
|
debug_print_swizzle(reg->swizzle));
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPSM_SIGNNEG:
|
|
|
|
return wine_dbg_sprintf("-%s%s_bx2%s", get_regname(reg),
|
|
|
|
debug_print_relarg(reg),
|
2022-02-09 16:30:05 +01:00
|
|
|
debug_print_swizzle(reg->swizzle));
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPSM_COMP:
|
|
|
|
return wine_dbg_sprintf("1 - %s%s%s", get_regname(reg),
|
|
|
|
debug_print_relarg(reg),
|
2022-02-09 16:30:05 +01:00
|
|
|
debug_print_swizzle(reg->swizzle));
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPSM_X2:
|
|
|
|
return wine_dbg_sprintf("%s%s_x2%s", get_regname(reg),
|
|
|
|
debug_print_relarg(reg),
|
2022-02-09 16:30:05 +01:00
|
|
|
debug_print_swizzle(reg->swizzle));
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPSM_X2NEG:
|
|
|
|
return wine_dbg_sprintf("-%s%s_x2%s", get_regname(reg),
|
|
|
|
debug_print_relarg(reg),
|
2022-02-09 16:30:05 +01:00
|
|
|
debug_print_swizzle(reg->swizzle));
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPSM_DZ:
|
|
|
|
return wine_dbg_sprintf("%s%s_dz%s", get_regname(reg),
|
|
|
|
debug_print_relarg(reg),
|
2022-02-09 16:30:05 +01:00
|
|
|
debug_print_swizzle(reg->swizzle));
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPSM_DW:
|
|
|
|
return wine_dbg_sprintf("%s%s_dw%s", get_regname(reg),
|
|
|
|
debug_print_relarg(reg),
|
2022-02-09 16:30:05 +01:00
|
|
|
debug_print_swizzle(reg->swizzle));
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPSM_ABS:
|
|
|
|
return wine_dbg_sprintf("%s%s_abs%s", get_regname(reg),
|
|
|
|
debug_print_relarg(reg),
|
2022-02-09 16:30:05 +01:00
|
|
|
debug_print_swizzle(reg->swizzle));
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPSM_ABSNEG:
|
|
|
|
return wine_dbg_sprintf("-%s%s_abs%s", get_regname(reg),
|
|
|
|
debug_print_relarg(reg),
|
2022-02-09 16:30:05 +01:00
|
|
|
debug_print_swizzle(reg->swizzle));
|
2010-10-18 13:05:50 +02:00
|
|
|
case BWRITERSPSM_NOT:
|
|
|
|
return wine_dbg_sprintf("!%s%s%s", get_regname(reg),
|
|
|
|
debug_print_relarg(reg),
|
2022-02-09 16:30:05 +01:00
|
|
|
debug_print_swizzle(reg->swizzle));
|
2010-10-18 13:05:50 +02:00
|
|
|
}
|
|
|
|
return "Unknown modifier";
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:30:05 +01:00
|
|
|
const char *debug_print_comp(uint32_t comp)
|
2010-10-18 13:05:50 +02:00
|
|
|
{
|
|
|
|
switch (comp)
|
|
|
|
{
|
|
|
|
case BWRITER_COMPARISON_NONE: return "";
|
|
|
|
case BWRITER_COMPARISON_GT: return "_gt";
|
|
|
|
case BWRITER_COMPARISON_EQ: return "_eq";
|
|
|
|
case BWRITER_COMPARISON_GE: return "_ge";
|
|
|
|
case BWRITER_COMPARISON_LT: return "_lt";
|
|
|
|
case BWRITER_COMPARISON_NE: return "_ne";
|
|
|
|
case BWRITER_COMPARISON_LE: return "_le";
|
|
|
|
default: return "_unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:30:05 +01:00
|
|
|
const char *debug_print_opcode(uint32_t opcode)
|
2010-10-18 13:05:50 +02:00
|
|
|
{
|
|
|
|
switch (opcode)
|
|
|
|
{
|
|
|
|
case BWRITERSIO_NOP: return "nop";
|
|
|
|
case BWRITERSIO_MOV: return "mov";
|
|
|
|
case BWRITERSIO_ADD: return "add";
|
|
|
|
case BWRITERSIO_SUB: return "sub";
|
|
|
|
case BWRITERSIO_MAD: return "mad";
|
|
|
|
case BWRITERSIO_MUL: return "mul";
|
|
|
|
case BWRITERSIO_RCP: return "rcp";
|
|
|
|
case BWRITERSIO_RSQ: return "rsq";
|
|
|
|
case BWRITERSIO_DP3: return "dp3";
|
|
|
|
case BWRITERSIO_DP4: return "dp4";
|
|
|
|
case BWRITERSIO_MIN: return "min";
|
|
|
|
case BWRITERSIO_MAX: return "max";
|
|
|
|
case BWRITERSIO_SLT: return "slt";
|
|
|
|
case BWRITERSIO_SGE: return "sge";
|
|
|
|
case BWRITERSIO_EXP: return "exp";
|
|
|
|
case BWRITERSIO_LOG: return "log";
|
|
|
|
case BWRITERSIO_LIT: return "lit";
|
|
|
|
case BWRITERSIO_DST: return "dst";
|
|
|
|
case BWRITERSIO_LRP: return "lrp";
|
|
|
|
case BWRITERSIO_FRC: return "frc";
|
|
|
|
case BWRITERSIO_M4x4: return "m4x4";
|
|
|
|
case BWRITERSIO_M4x3: return "m4x3";
|
|
|
|
case BWRITERSIO_M3x4: return "m3x4";
|
|
|
|
case BWRITERSIO_M3x3: return "m3x3";
|
|
|
|
case BWRITERSIO_M3x2: return "m3x2";
|
|
|
|
case BWRITERSIO_CALL: return "call";
|
|
|
|
case BWRITERSIO_CALLNZ: return "callnz";
|
|
|
|
case BWRITERSIO_LOOP: return "loop";
|
|
|
|
case BWRITERSIO_RET: return "ret";
|
|
|
|
case BWRITERSIO_ENDLOOP: return "endloop";
|
|
|
|
case BWRITERSIO_LABEL: return "label";
|
|
|
|
case BWRITERSIO_DCL: return "dcl";
|
|
|
|
case BWRITERSIO_POW: return "pow";
|
|
|
|
case BWRITERSIO_CRS: return "crs";
|
|
|
|
case BWRITERSIO_SGN: return "sgn";
|
|
|
|
case BWRITERSIO_ABS: return "abs";
|
|
|
|
case BWRITERSIO_NRM: return "nrm";
|
|
|
|
case BWRITERSIO_SINCOS: return "sincos";
|
|
|
|
case BWRITERSIO_REP: return "rep";
|
|
|
|
case BWRITERSIO_ENDREP: return "endrep";
|
|
|
|
case BWRITERSIO_IF: return "if";
|
|
|
|
case BWRITERSIO_IFC: return "ifc";
|
|
|
|
case BWRITERSIO_ELSE: return "else";
|
|
|
|
case BWRITERSIO_ENDIF: return "endif";
|
|
|
|
case BWRITERSIO_BREAK: return "break";
|
|
|
|
case BWRITERSIO_BREAKC: return "breakc";
|
|
|
|
case BWRITERSIO_MOVA: return "mova";
|
|
|
|
case BWRITERSIO_DEFB: return "defb";
|
|
|
|
case BWRITERSIO_DEFI: return "defi";
|
|
|
|
case BWRITERSIO_TEXCOORD: return "texcoord";
|
|
|
|
case BWRITERSIO_TEXKILL: return "texkill";
|
|
|
|
case BWRITERSIO_TEX: return "tex";
|
|
|
|
case BWRITERSIO_TEXBEM: return "texbem";
|
|
|
|
case BWRITERSIO_TEXBEML: return "texbeml";
|
|
|
|
case BWRITERSIO_TEXREG2AR: return "texreg2ar";
|
|
|
|
case BWRITERSIO_TEXREG2GB: return "texreg2gb";
|
|
|
|
case BWRITERSIO_TEXM3x2PAD: return "texm3x2pad";
|
|
|
|
case BWRITERSIO_TEXM3x2TEX: return "texm3x2tex";
|
|
|
|
case BWRITERSIO_TEXM3x3PAD: return "texm3x3pad";
|
|
|
|
case BWRITERSIO_TEXM3x3TEX: return "texm3x3tex";
|
|
|
|
case BWRITERSIO_TEXM3x3SPEC: return "texm3x3vspec";
|
|
|
|
case BWRITERSIO_TEXM3x3VSPEC: return "texm3x3vspec";
|
|
|
|
case BWRITERSIO_EXPP: return "expp";
|
|
|
|
case BWRITERSIO_LOGP: return "logp";
|
|
|
|
case BWRITERSIO_CND: return "cnd";
|
|
|
|
case BWRITERSIO_DEF: return "def";
|
|
|
|
case BWRITERSIO_TEXREG2RGB: return "texreg2rgb";
|
|
|
|
case BWRITERSIO_TEXDP3TEX: return "texdp3tex";
|
|
|
|
case BWRITERSIO_TEXM3x2DEPTH: return "texm3x2depth";
|
|
|
|
case BWRITERSIO_TEXDP3: return "texdp3";
|
|
|
|
case BWRITERSIO_TEXM3x3: return "texm3x3";
|
|
|
|
case BWRITERSIO_TEXDEPTH: return "texdepth";
|
|
|
|
case BWRITERSIO_CMP: return "cmp";
|
|
|
|
case BWRITERSIO_BEM: return "bem";
|
|
|
|
case BWRITERSIO_DP2ADD: return "dp2add";
|
|
|
|
case BWRITERSIO_DSX: return "dsx";
|
|
|
|
case BWRITERSIO_DSY: return "dsy";
|
|
|
|
case BWRITERSIO_TEXLDD: return "texldd";
|
|
|
|
case BWRITERSIO_SETP: return "setp";
|
|
|
|
case BWRITERSIO_TEXLDL: return "texldl";
|
|
|
|
case BWRITERSIO_BREAKP: return "breakp";
|
|
|
|
case BWRITERSIO_PHASE: return "phase";
|
|
|
|
|
|
|
|
case BWRITERSIO_TEXLDP: return "texldp";
|
|
|
|
case BWRITERSIO_TEXLDB: return "texldb";
|
|
|
|
|
|
|
|
default: return "unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:30:05 +01:00
|
|
|
void skip_u32_unknown(const char **ptr, unsigned int count)
|
2010-10-03 15:11:54 +02:00
|
|
|
{
|
|
|
|
unsigned int i;
|
2022-02-09 16:30:05 +01:00
|
|
|
uint32_t u32;
|
2010-10-03 15:11:54 +02:00
|
|
|
|
2022-02-09 16:30:05 +01:00
|
|
|
FIXME("Skipping %u unknown u32s:\n", count);
|
2010-10-03 15:11:54 +02:00
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
{
|
2022-02-09 16:30:05 +01:00
|
|
|
u32 = read_u32(ptr);
|
|
|
|
FIXME("\t0x%08x\n", u32);
|
2010-10-03 15:11:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:30:05 +01:00
|
|
|
static void write_u32_unknown(char **ptr, uint32_t u32)
|
2010-10-03 15:11:54 +02:00
|
|
|
{
|
2022-02-09 16:30:05 +01:00
|
|
|
FIXME("Writing unknown u32 0x%08x.\n", u32);
|
|
|
|
write_u32(ptr, u32);
|
2010-10-03 15:11:54 +02:00
|
|
|
}
|
|
|
|
|
2022-02-09 16:30:05 +01:00
|
|
|
HRESULT dxbc_add_section(struct dxbc *dxbc, DWORD tag, const char *data, size_t data_size)
|
2010-10-03 15:11:54 +02:00
|
|
|
{
|
2022-02-09 16:30:05 +01:00
|
|
|
TRACE("dxbc %p, tag %s, size %#Ix.\n", dxbc, debugstr_an((const char *)&tag, 4), data_size);
|
2010-10-03 15:11:54 +02:00
|
|
|
|
|
|
|
if (dxbc->count >= dxbc->size)
|
|
|
|
{
|
|
|
|
struct dxbc_section *new_sections;
|
|
|
|
DWORD new_size = dxbc->size << 1;
|
|
|
|
|
|
|
|
new_sections = HeapReAlloc(GetProcessHeap(), 0, dxbc->sections, new_size * sizeof(*dxbc->sections));
|
|
|
|
if (!new_sections)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate dxbc section memory\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
dxbc->sections = new_sections;
|
|
|
|
dxbc->size = new_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
dxbc->sections[dxbc->count].tag = tag;
|
|
|
|
dxbc->sections[dxbc->count].data_size = data_size;
|
|
|
|
dxbc->sections[dxbc->count].data = data;
|
|
|
|
++dxbc->count;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2018-12-19 23:06:46 +01:00
|
|
|
HRESULT dxbc_init(struct dxbc *dxbc, unsigned int size)
|
2010-10-03 15:11:54 +02:00
|
|
|
{
|
|
|
|
TRACE("dxbc %p, size %u.\n", dxbc, size);
|
|
|
|
|
|
|
|
/* use a good starting value for the size if none specified */
|
|
|
|
if (!size) size = 2;
|
|
|
|
|
|
|
|
dxbc->sections = HeapAlloc(GetProcessHeap(), 0, size * sizeof(*dxbc->sections));
|
|
|
|
if (!dxbc->sections)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate dxbc section memory\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
dxbc->size = size;
|
|
|
|
dxbc->count = 0;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT dxbc_parse(const char *data, SIZE_T data_size, struct dxbc *dxbc)
|
|
|
|
{
|
2022-02-09 16:30:05 +01:00
|
|
|
uint32_t tag, total_size, chunk_count;
|
2010-10-03 15:11:54 +02:00
|
|
|
const char *ptr = data;
|
|
|
|
unsigned int i;
|
2022-02-09 16:30:05 +01:00
|
|
|
HRESULT hr;
|
2010-10-03 15:11:54 +02:00
|
|
|
|
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
WARN("No data supplied.\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:30:05 +01:00
|
|
|
tag = read_u32(&ptr);
|
2010-10-03 15:11:54 +02:00
|
|
|
TRACE("tag: %s.\n", debugstr_an((const char *)&tag, 4));
|
|
|
|
|
|
|
|
if (tag != TAG_DXBC)
|
|
|
|
{
|
|
|
|
WARN("Wrong tag.\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* checksum? */
|
2022-02-09 16:30:05 +01:00
|
|
|
skip_u32_unknown(&ptr, 4);
|
2010-10-03 15:11:54 +02:00
|
|
|
|
2022-02-09 16:30:05 +01:00
|
|
|
skip_u32_unknown(&ptr, 1);
|
2010-10-03 15:11:54 +02:00
|
|
|
|
2022-02-09 16:30:05 +01:00
|
|
|
total_size = read_u32(&ptr);
|
|
|
|
TRACE("total size: %#x\n", total_size);
|
2010-10-03 15:11:54 +02:00
|
|
|
|
|
|
|
if (data_size != total_size)
|
|
|
|
{
|
|
|
|
WARN("Wrong size supplied.\n");
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:30:05 +01:00
|
|
|
chunk_count = read_u32(&ptr);
|
|
|
|
TRACE("chunk count: %#x\n", chunk_count);
|
2010-10-03 15:11:54 +02:00
|
|
|
|
|
|
|
hr = dxbc_init(dxbc, chunk_count);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to init dxbc\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < chunk_count; ++i)
|
|
|
|
{
|
2022-02-09 16:30:05 +01:00
|
|
|
uint32_t chunk_tag, chunk_size;
|
2010-10-03 15:11:54 +02:00
|
|
|
const char *chunk_ptr;
|
2022-02-09 16:30:05 +01:00
|
|
|
uint32_t chunk_offset;
|
2010-10-03 15:11:54 +02:00
|
|
|
|
2022-02-09 16:30:05 +01:00
|
|
|
chunk_offset = read_u32(&ptr);
|
|
|
|
TRACE("chunk %u at offset %#x\n", i, chunk_offset);
|
2010-10-03 15:11:54 +02:00
|
|
|
|
|
|
|
chunk_ptr = data + chunk_offset;
|
|
|
|
|
2022-02-09 16:30:05 +01:00
|
|
|
chunk_tag = read_u32(&chunk_ptr);
|
|
|
|
chunk_size = read_u32(&chunk_ptr);
|
2010-10-03 15:11:54 +02:00
|
|
|
|
|
|
|
hr = dxbc_add_section(dxbc, chunk_tag, chunk_ptr, chunk_size);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to add section to dxbc\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void dxbc_destroy(struct dxbc *dxbc)
|
|
|
|
{
|
|
|
|
TRACE("dxbc %p.\n", dxbc);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, dxbc->sections);
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT dxbc_write_blob(struct dxbc *dxbc, ID3DBlob **blob)
|
|
|
|
{
|
|
|
|
DWORD size = 32, offset = size + 4 * dxbc->count;
|
|
|
|
ID3DBlob *object;
|
|
|
|
HRESULT hr;
|
|
|
|
char *ptr;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
TRACE("dxbc %p, blob %p.\n", dxbc, blob);
|
|
|
|
|
|
|
|
for (i = 0; i < dxbc->count; ++i)
|
|
|
|
{
|
|
|
|
size += 12 + dxbc->sections[i].data_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = D3DCreateBlob(size, &object);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to create blob\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
ptr = ID3D10Blob_GetBufferPointer(object);
|
|
|
|
|
2022-02-09 16:30:05 +01:00
|
|
|
write_u32(&ptr, TAG_DXBC);
|
2010-10-03 15:11:54 +02:00
|
|
|
|
|
|
|
/* signature(?) */
|
2022-02-09 16:30:05 +01:00
|
|
|
write_u32_unknown(&ptr, 0);
|
|
|
|
write_u32_unknown(&ptr, 0);
|
|
|
|
write_u32_unknown(&ptr, 0);
|
|
|
|
write_u32_unknown(&ptr, 0);
|
2010-10-03 15:11:54 +02:00
|
|
|
|
|
|
|
/* seems to be always 1 */
|
2022-02-09 16:30:05 +01:00
|
|
|
write_u32_unknown(&ptr, 1);
|
2010-10-03 15:11:54 +02:00
|
|
|
|
|
|
|
/* DXBC size */
|
2022-02-09 16:30:05 +01:00
|
|
|
write_u32(&ptr, size);
|
2010-10-03 15:11:54 +02:00
|
|
|
|
|
|
|
/* chunk count */
|
2022-02-09 16:30:05 +01:00
|
|
|
write_u32(&ptr, dxbc->count);
|
2010-10-03 15:11:54 +02:00
|
|
|
|
|
|
|
/* write the chunk offsets */
|
|
|
|
for (i = 0; i < dxbc->count; ++i)
|
|
|
|
{
|
2022-02-09 16:30:05 +01:00
|
|
|
write_u32(&ptr, offset);
|
2010-10-03 15:11:54 +02:00
|
|
|
offset += 8 + dxbc->sections[i].data_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* write the chunks */
|
|
|
|
for (i = 0; i < dxbc->count; ++i)
|
|
|
|
{
|
2022-02-09 16:30:05 +01:00
|
|
|
write_u32(&ptr, dxbc->sections[i].tag);
|
|
|
|
write_u32(&ptr, dxbc->sections[i].data_size);
|
2010-10-03 15:11:54 +02:00
|
|
|
memcpy(ptr, dxbc->sections[i].data, dxbc->sections[i].data_size);
|
|
|
|
ptr += dxbc->sections[i].data_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Created ID3DBlob %p\n", object);
|
|
|
|
|
|
|
|
*blob = object;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2012-05-08 16:17:31 +02:00
|
|
|
|
2021-10-22 11:11:28 +02:00
|
|
|
void compilation_message(struct compilation_messages *msg, const char *fmt, va_list args)
|
2012-05-08 16:17:31 +02:00
|
|
|
{
|
|
|
|
char* buffer;
|
|
|
|
int rc, size;
|
|
|
|
|
|
|
|
if (msg->capacity == 0)
|
|
|
|
{
|
2012-05-08 16:17:32 +02:00
|
|
|
msg->string = d3dcompiler_alloc(MESSAGEBUFFER_INITIAL_SIZE);
|
2012-05-08 16:17:31 +02:00
|
|
|
if (msg->string == NULL)
|
|
|
|
{
|
|
|
|
ERR("Error allocating memory for parser messages\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
msg->capacity = MESSAGEBUFFER_INITIAL_SIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
rc = vsnprintf(msg->string + msg->size,
|
|
|
|
msg->capacity - msg->size, fmt, args);
|
|
|
|
|
|
|
|
if (rc < 0 || rc >= msg->capacity - msg->size)
|
|
|
|
{
|
|
|
|
size = msg->capacity * 2;
|
2012-05-08 16:17:32 +02:00
|
|
|
buffer = d3dcompiler_realloc(msg->string, size);
|
2012-05-08 16:17:31 +02:00
|
|
|
if (buffer == NULL)
|
|
|
|
{
|
|
|
|
ERR("Error reallocating memory for parser messages\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
msg->string = buffer;
|
|
|
|
msg->capacity = size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-05-15 16:12:55 +02:00
|
|
|
TRACE("%s", msg->string + msg->size);
|
2012-05-08 16:17:31 +02:00
|
|
|
msg->size += rc;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|