d3dcompiler: Set correct compilation target for effects profiles.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
parent
e21244f7a3
commit
d01ae1512f
2 changed files with 47 additions and 41 deletions
|
@ -397,29 +397,12 @@ HRESULT WINAPI D3DAssemble(const void *data, SIZE_T datasize, const char *filena
|
|||
return hr;
|
||||
}
|
||||
|
||||
HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filename,
|
||||
const D3D_SHADER_MACRO *macros, ID3DInclude *include, const char *entry_point,
|
||||
const char *profile, UINT flags, UINT effect_flags, UINT secondary_flags,
|
||||
const void *secondary_data, SIZE_T secondary_data_size, ID3DBlob **shader_blob,
|
||||
ID3DBlob **messages_blob)
|
||||
static enum vkd3d_shader_target_type get_target_for_profile(const char *profile)
|
||||
{
|
||||
struct d3dcompiler_include_from_file include_from_file;
|
||||
struct vkd3d_shader_preprocess_info preprocess_info;
|
||||
struct vkd3d_shader_hlsl_source_info hlsl_info;
|
||||
struct vkd3d_shader_compile_option options[4];
|
||||
struct vkd3d_shader_compile_info compile_info;
|
||||
struct vkd3d_shader_compile_option *option;
|
||||
struct vkd3d_shader_code byte_code;
|
||||
const D3D_SHADER_MACRO *macro;
|
||||
size_t profile_len, i;
|
||||
char *messages;
|
||||
HRESULT hr;
|
||||
int ret;
|
||||
|
||||
static const char * const d3dbc_profiles[] =
|
||||
{
|
||||
"fx_2_",
|
||||
|
||||
"ps.1.",
|
||||
"ps.2.",
|
||||
"ps.3.",
|
||||
|
@ -439,6 +422,50 @@ HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filen
|
|||
"tx_1_",
|
||||
};
|
||||
|
||||
static const char * const fx_profiles[] =
|
||||
{
|
||||
"fx_2_0",
|
||||
"fx_4_0",
|
||||
"fx_4_1",
|
||||
"fx_5_0",
|
||||
};
|
||||
|
||||
profile_len = strlen(profile);
|
||||
for (i = 0; i < ARRAY_SIZE(d3dbc_profiles); ++i)
|
||||
{
|
||||
size_t len = strlen(d3dbc_profiles[i]);
|
||||
|
||||
if (len <= profile_len && !memcmp(profile, d3dbc_profiles[i], len))
|
||||
return VKD3D_SHADER_TARGET_D3D_BYTECODE;
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(fx_profiles); ++i)
|
||||
{
|
||||
if (!strcmp(profile, fx_profiles[i]))
|
||||
return VKD3D_SHADER_TARGET_FX;
|
||||
}
|
||||
|
||||
return VKD3D_SHADER_TARGET_DXBC_TPF;
|
||||
}
|
||||
|
||||
HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filename,
|
||||
const D3D_SHADER_MACRO *macros, ID3DInclude *include, const char *entry_point,
|
||||
const char *profile, UINT flags, UINT effect_flags, UINT secondary_flags,
|
||||
const void *secondary_data, SIZE_T secondary_data_size, ID3DBlob **shader_blob,
|
||||
ID3DBlob **messages_blob)
|
||||
{
|
||||
struct d3dcompiler_include_from_file include_from_file;
|
||||
struct vkd3d_shader_preprocess_info preprocess_info;
|
||||
struct vkd3d_shader_hlsl_source_info hlsl_info;
|
||||
struct vkd3d_shader_compile_option options[4];
|
||||
struct vkd3d_shader_compile_info compile_info;
|
||||
struct vkd3d_shader_compile_option *option;
|
||||
struct vkd3d_shader_code byte_code;
|
||||
const D3D_SHADER_MACRO *macro;
|
||||
char *messages;
|
||||
HRESULT hr;
|
||||
int ret;
|
||||
|
||||
TRACE("data %p, data_size %Iu, filename %s, macros %p, include %p, entry_point %s, "
|
||||
"profile %s, flags %#x, effect_flags %#x, secondary_flags %#x, secondary_data %p, "
|
||||
"secondary_data_size %Iu, shader_blob %p, messages_blob %p.\n",
|
||||
|
@ -477,24 +504,12 @@ HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filen
|
|||
compile_info.source.code = data;
|
||||
compile_info.source.size = data_size;
|
||||
compile_info.source_type = VKD3D_SHADER_SOURCE_HLSL;
|
||||
compile_info.target_type = VKD3D_SHADER_TARGET_DXBC_TPF;
|
||||
compile_info.target_type = get_target_for_profile(profile);
|
||||
compile_info.options = options;
|
||||
compile_info.option_count = 1;
|
||||
compile_info.log_level = VKD3D_SHADER_LOG_INFO;
|
||||
compile_info.source_name = filename;
|
||||
|
||||
profile_len = strlen(profile);
|
||||
for (i = 0; i < ARRAY_SIZE(d3dbc_profiles); ++i)
|
||||
{
|
||||
size_t len = strlen(d3dbc_profiles[i]);
|
||||
|
||||
if (len <= profile_len && !memcmp(profile, d3dbc_profiles[i], len))
|
||||
{
|
||||
compile_info.target_type = VKD3D_SHADER_TARGET_D3D_BYTECODE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
preprocess_info.type = VKD3D_SHADER_STRUCTURE_TYPE_PREPROCESS_INFO;
|
||||
preprocess_info.next = &hlsl_info;
|
||||
preprocess_info.macros = (const struct vkd3d_shader_macro *)macros;
|
||||
|
|
|
@ -257,12 +257,7 @@ static void test_create_effect_and_pool(IDirect3DDevice9 *device)
|
|||
ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
|
||||
|
||||
hr = D3DXCreateEffect(device, effect_desc, sizeof(effect_desc), NULL, NULL, 0, NULL, &effect, NULL);
|
||||
todo_wine ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
skip("Failed to compile effect, skipping test.\n");
|
||||
return;
|
||||
}
|
||||
ok(hr == D3D_OK, "Got result %lx, expected 0 (D3D_OK)\n", hr);
|
||||
|
||||
hr = effect->lpVtbl->QueryInterface(effect, &IID_ID3DXBaseEffect, (void **)&base);
|
||||
ok(hr == E_NOINTERFACE, "QueryInterface failed, got %lx, expected %lx (E_NOINTERFACE)\n", hr, E_NOINTERFACE);
|
||||
|
@ -8041,15 +8036,12 @@ static void test_create_effect_from_file(void)
|
|||
/* This is apparently broken on native, it ends up using the wrong include. */
|
||||
hr = D3DXCreateEffectFromFileExW(device, filename_w, NULL, NULL, NULL,
|
||||
0, NULL, &effect, &messages);
|
||||
todo_wine
|
||||
ok(hr == E_FAIL, "Unexpected error, hr %#lx.\n", hr);
|
||||
if (messages)
|
||||
{
|
||||
trace("D3DXCreateEffectFromFileExW messages:\n%s", (char *)ID3DXBuffer_GetBufferPointer(messages));
|
||||
ID3DXBuffer_Release(messages);
|
||||
}
|
||||
if (effect)
|
||||
effect->lpVtbl->Release(effect);
|
||||
|
||||
delete_file("effect1.fx");
|
||||
delete_file("effect2.fx");
|
||||
|
@ -8067,7 +8059,6 @@ static void test_create_effect_from_file(void)
|
|||
* is "ID3DXEffectCompiler: There were no techniques" */
|
||||
hr = D3DXCreateEffectFromFileExW(device, filename_w, NULL, &include.ID3DXInclude_iface, NULL,
|
||||
0, NULL, &effect, &messages);
|
||||
todo_wine
|
||||
ok(hr == E_FAIL, "D3DXInclude test failed with error %#lx.\n", hr);
|
||||
if (messages)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue