Re: [PATCH] d3dcompiler: Add a LUT to find compilation targets info. (try 3)

2013-05-10 Thread Alexandre Julliard
Christian Costa titan.co...@gmail.com writes:

 -if (strlen(target) != 6 || target[1] != 's' || target[2] != '_' || 
 target[4] != '_')
 +for (i = 0; i  nb_targets; i++)
  {
 -FIXME(Unknown compilation target %s.\n, debugstr_a(target));
 -return D3DERR_INVALIDCALL;
 +if (!strcmp(target, targets_info[i].name) ||
 +(targets_info[i].altname  !strcmp(target, 
 targets_info[i].altname)))

A binary search would be much better.

-- 
Alexandre Julliard
julli...@winehq.org




Re: [PATCH] d3dcompiler: Add a LUT to find compilation targets info. (try 3)

2013-05-10 Thread Christian Costa

Le 10/05/2013 16:37, Alexandre Julliard a écrit :

Christian Costa titan.co...@gmail.com writes:


-if (strlen(target) != 6 || target[1] != 's' || target[2] != '_' || 
target[4] != '_')
+for (i = 0; i  nb_targets; i++)
  {
-FIXME(Unknown compilation target %s.\n, debugstr_a(target));
-return D3DERR_INVALIDCALL;
+if (!strcmp(target, targets_info[i].name) ||
+(targets_info[i].altname  !strcmp(target, 
targets_info[i].altname)))

A binary search would be much better.


Isn't the array a bit small for that?
I can do it but in that case alternate names will be entries like others.




Re: [PATCH] d3dcompiler: Add a LUT to find compilation targets info.

2013-05-03 Thread Matteo Bruni
2013/5/2 Christian Costa titan.co...@gmail.com:

 ---
  dlls/d3dcompiler_43/compiler.c|  101 
 +++--
  dlls/d3dcompiler_43/d3dcompiler_private.h |1
  2 files changed, 81 insertions(+), 21 deletions(-)

 diff --git a/dlls/d3dcompiler_43/compiler.c b/dlls/d3dcompiler_43/compiler.c
 index 4942985..a6a9867 100644
 --- a/dlls/d3dcompiler_43/compiler.c
 +++ b/dlls/d3dcompiler_43/compiler.c
 @@ -490,6 +490,66 @@ HRESULT WINAPI D3DAssemble(const void *data, SIZE_T 
 datasize, const char *filena
  return hr;
  }

 +struct {

Please make it static const.

 +const char *name;
 +enum shader_type type;
 +DWORD sm_major;
 +DWORD sm_minor;
 +DWORD level_major;
 +DWORD level_minor;
 +BOOL sw;
 +BOOL support;
 +} targets_info[] = {
 +/* SM 1 */
 +{ vs_1_0,ST_VERTEX,  1, 0, 0, 0, FALSE, TRUE  },
 +{ vs_1_1,ST_VERTEX,  1, 1, 0, 0, FALSE, TRUE  },
 +{ ps_1_0,ST_PIXEL,   1, 0, 0, 0, FALSE, TRUE  },
 +{ ps_1_1,ST_PIXEL,   1, 1, 0, 0, FALSE, FALSE },
 +{ ps_1_2,ST_PIXEL,   1, 2, 0, 0, FALSE, FALSE },
 +{ ps_1_3,ST_PIXEL,   1, 3, 0, 0, FALSE, FALSE },
 +{ ps_1_4,ST_PIXEL,   1, 4, 0, 0, FALSE, FALSE },
 +{ tx_1_0,ST_UNKNOWN, 1, 0, 0, 0, FALSE, FALSE },
 +/* SM 2 */
 +{ vs_2_0,ST_VERTEX,  2, 0, 0, 0, FALSE, TRUE  },
 +{ vs_2_a,ST_VERTEX,  2, 1, 0, 0, FALSE, FALSE },
 +{ vs_2_sw,   ST_VERTEX,  2, 0, 0, 0, TRUE,  FALSE },
 +{ ps_2_0,ST_PIXEL,   2, 0, 0, 0, FALSE, TRUE  },
 +{ ps_2_a,ST_PIXEL,   2, 1, 0, 0, FALSE, FALSE },
 +{ ps_2_b,ST_PIXEL,   2, 2, 0, 0, FALSE, FALSE },
 +{ ps_2_sw,   ST_PIXEL,   2, 0, 0, 0, TRUE,  FALSE },
 +{ fx_2_0,ST_UNKNOWN, 2, 0, 0, 0, FALSE, FALSE },
 +/* SM 3 */
 +{ vs_3_0,ST_VERTEX,  3, 0, 0, 0, FALSE, TRUE  },
 +{ vs_3_sw,   ST_VERTEX,  3, 0, 0, 0, TRUE,  FALSE },
 +{ ps_3_0,ST_PIXEL,   3, 0, 0, 0, FALSE, TRUE  },
 +{ ps_3_sw,   ST_PIXEL,   3, 0, 0, 0, TRUE,  FALSE },
 +/* SM 4 */
 +{ vs_4_0_level_9_0,  ST_VERTEX,  4, 0, 9, 0, FALSE, FALSE },
 +{ vs_4_0_level_9_1,  ST_VERTEX,  4, 0, 9, 1, FALSE, FALSE },
 +{ vs_4_0_level_9_3,  ST_VERTEX,  4, 0, 9, 3, FALSE, FALSE },
 +{ vs_4_0,ST_VERTEX,  4, 0, 0, 0, FALSE, TRUE  },
 +{ vs_4_1,ST_VERTEX,  4, 1, 0, 0, FALSE, TRUE  },
 +{ ps_4_0_level_9_0,  ST_PIXEL,   4, 0, 9, 0, FALSE, FALSE },
 +{ ps_4_0_level_9_1,  ST_PIXEL,   4, 0, 9, 1, FALSE, FALSE },
 +{ ps_4_0_level_9_3,  ST_PIXEL,   4, 0, 9, 3, FALSE, FALSE },
 +{ ps_4_0,ST_PIXEL,   4, 0, 0, 0, FALSE, TRUE  },
 +{ ps_4_1,ST_PIXEL,   4, 1, 0, 0, FALSE, TRUE  },
 +{ gs_4_0,ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
 +{ gs_4_1,ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
 +{ cs_4_0,ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
 +{ cs_4_1,ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
 +{ fx_4_0,ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
 +{ fx_4_1,ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
 +/* SM 5 */
 +{ vs_5_0,ST_VERTEX,  5, 0, 0, 0, FALSE, TRUE  },
 +{ ps_5_0,ST_PIXEL,   5, 0, 0, 0, FALSE, TRUE  },
 +{ hs_5_0,ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
 +{ gs_5_0,ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
 +{ ds_5_0,ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
 +{ cs_5_0,ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
 +{ fx_5_0,ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
 +};
 +
  static HRESULT compile_shader(const char *preproc_shader, const char 
 *target, const char *entrypoint,
  ID3DBlob **shader_blob, ID3DBlob **error_messages)
  {
 @@ -500,38 +560,37 @@ static HRESULT compile_shader(const char 
 *preproc_shader, const char *target, co
  ID3DBlob *buffer;
  char *pos;
  enum shader_type shader_type;
 +ULONG i;
 +ULONG nb = sizeof(targets_info) / sizeof(targets_info[0]);

  TRACE(Preprocessed shader source: %s\n, debugstr_a(preproc_shader));

  TRACE(Parsing compilation target %s.\n, debugstr_a(target));
 -if (strlen(target) != 6 || target[1] != 's' || target[2] != '_' || 
 target[4] != '_')
 +for (i = 0; i  nb; i++)
  {
 -FIXME(Unknown compilation target %s.\n, debugstr_a(target));
 -return D3DERR_INVALIDCALL;
 +if (!strcmp(target, targets_info[i].name))
 +{
 +if (!targets_info[i].support)
 +{
 +FIXME(Compilation target %s not yet supported\n, 
 debugstr_a(target));
 +return D3DERR_INVALIDCALL;
 +}
 +else
 +{
 +shader_type = targets_info[i].type;
 +major = 

Re: [PATCH] d3dcompiler: Add a LUT to find compilation targets info.

2013-05-03 Thread Christian Costa
2013/5/3 Matteo Bruni matteo.myst...@gmail.com

 2013/5/2 Christian Costa titan.co...@gmail.com:
 
  ---
   dlls/d3dcompiler_43/compiler.c|  101
 +++--
   dlls/d3dcompiler_43/d3dcompiler_private.h |1
   2 files changed, 81 insertions(+), 21 deletions(-)
 
  diff --git a/dlls/d3dcompiler_43/compiler.c
 b/dlls/d3dcompiler_43/compiler.c
  index 4942985..a6a9867 100644
  --- a/dlls/d3dcompiler_43/compiler.c
  +++ b/dlls/d3dcompiler_43/compiler.c
  @@ -490,6 +490,66 @@ HRESULT WINAPI D3DAssemble(const void *data, SIZE_T
 datasize, const char *filena
   return hr;
   }
 
  +struct {

 Please make it static const.

  +const char *name;
  +enum shader_type type;
  +DWORD sm_major;
  +DWORD sm_minor;
  +DWORD level_major;
  +DWORD level_minor;
  +BOOL sw;
  +BOOL support;
  +} targets_info[] = {
  +/* SM 1 */
  +{ vs_1_0,ST_VERTEX,  1, 0, 0, 0, FALSE, TRUE  },
  +{ vs_1_1,ST_VERTEX,  1, 1, 0, 0, FALSE, TRUE  },
  +{ ps_1_0,ST_PIXEL,   1, 0, 0, 0, FALSE, TRUE  },
  +{ ps_1_1,ST_PIXEL,   1, 1, 0, 0, FALSE, FALSE },
  +{ ps_1_2,ST_PIXEL,   1, 2, 0, 0, FALSE, FALSE },
  +{ ps_1_3,ST_PIXEL,   1, 3, 0, 0, FALSE, FALSE },
  +{ ps_1_4,ST_PIXEL,   1, 4, 0, 0, FALSE, FALSE },
  +{ tx_1_0,ST_UNKNOWN, 1, 0, 0, 0, FALSE, FALSE },
  +/* SM 2 */
  +{ vs_2_0,ST_VERTEX,  2, 0, 0, 0, FALSE, TRUE  },
  +{ vs_2_a,ST_VERTEX,  2, 1, 0, 0, FALSE, FALSE },
  +{ vs_2_sw,   ST_VERTEX,  2, 0, 0, 0, TRUE,  FALSE },
  +{ ps_2_0,ST_PIXEL,   2, 0, 0, 0, FALSE, TRUE  },
  +{ ps_2_a,ST_PIXEL,   2, 1, 0, 0, FALSE, FALSE },
  +{ ps_2_b,ST_PIXEL,   2, 2, 0, 0, FALSE, FALSE },
  +{ ps_2_sw,   ST_PIXEL,   2, 0, 0, 0, TRUE,  FALSE },
  +{ fx_2_0,ST_UNKNOWN, 2, 0, 0, 0, FALSE, FALSE },
  +/* SM 3 */
  +{ vs_3_0,ST_VERTEX,  3, 0, 0, 0, FALSE, TRUE  },
  +{ vs_3_sw,   ST_VERTEX,  3, 0, 0, 0, TRUE,  FALSE },
  +{ ps_3_0,ST_PIXEL,   3, 0, 0, 0, FALSE, TRUE  },
  +{ ps_3_sw,   ST_PIXEL,   3, 0, 0, 0, TRUE,  FALSE },
  +/* SM 4 */
  +{ vs_4_0_level_9_0,  ST_VERTEX,  4, 0, 9, 0, FALSE, FALSE },
  +{ vs_4_0_level_9_1,  ST_VERTEX,  4, 0, 9, 1, FALSE, FALSE },
  +{ vs_4_0_level_9_3,  ST_VERTEX,  4, 0, 9, 3, FALSE, FALSE },
  +{ vs_4_0,ST_VERTEX,  4, 0, 0, 0, FALSE, TRUE  },
  +{ vs_4_1,ST_VERTEX,  4, 1, 0, 0, FALSE, TRUE  },
  +{ ps_4_0_level_9_0,  ST_PIXEL,   4, 0, 9, 0, FALSE, FALSE },
  +{ ps_4_0_level_9_1,  ST_PIXEL,   4, 0, 9, 1, FALSE, FALSE },
  +{ ps_4_0_level_9_3,  ST_PIXEL,   4, 0, 9, 3, FALSE, FALSE },
  +{ ps_4_0,ST_PIXEL,   4, 0, 0, 0, FALSE, TRUE  },
  +{ ps_4_1,ST_PIXEL,   4, 1, 0, 0, FALSE, TRUE  },
  +{ gs_4_0,ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
  +{ gs_4_1,ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
  +{ cs_4_0,ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
  +{ cs_4_1,ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
  +{ fx_4_0,ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
  +{ fx_4_1,ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
  +/* SM 5 */
  +{ vs_5_0,ST_VERTEX,  5, 0, 0, 0, FALSE, TRUE  },
  +{ ps_5_0,ST_PIXEL,   5, 0, 0, 0, FALSE, TRUE  },
  +{ hs_5_0,ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
  +{ gs_5_0,ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
  +{ ds_5_0,ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
  +{ cs_5_0,ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
  +{ fx_5_0,ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
  +};
  +
   static HRESULT compile_shader(const char *preproc_shader, const char
 *target, const char *entrypoint,
   ID3DBlob **shader_blob, ID3DBlob **error_messages)
   {
  @@ -500,38 +560,37 @@ static HRESULT compile_shader(const char
 *preproc_shader, const char *target, co
   ID3DBlob *buffer;
   char *pos;
   enum shader_type shader_type;
  +ULONG i;
  +ULONG nb = sizeof(targets_info) / sizeof(targets_info[0]);
 
   TRACE(Preprocessed shader source: %s\n,
 debugstr_a(preproc_shader));
 
   TRACE(Parsing compilation target %s.\n, debugstr_a(target));
  -if (strlen(target) != 6 || target[1] != 's' || target[2] != '_' ||
 target[4] != '_')
  +for (i = 0; i  nb; i++)
   {
  -FIXME(Unknown compilation target %s.\n, debugstr_a(target));
  -return D3DERR_INVALIDCALL;
  +if (!strcmp(target, targets_info[i].name))
  +{
  +if (!targets_info[i].support)
  +{
  +FIXME(Compilation target %s not yet supported\n,
 debugstr_a(target));
  +return D3DERR_INVALIDCALL;