From: Amine Khaldi Date: Sun, 21 Jan 2018 21:24:27 +0000 (+0100) Subject: [D3DX9_24=>43] Sync with Wine 3.0. CORE-14225 X-Git-Tag: 0.4.9-dev~257 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=65bd988c4043e0144547cb7cdad55ac690ec2144 [D3DX9_24=>43] Sync with Wine 3.0. CORE-14225 --- diff --git a/dll/directx/wine/d3dx9_36/d3dx9_36.spec b/dll/directx/wine/d3dx9_36/d3dx9_36.spec index e073d6e5372..e487aa12ec8 100644 --- a/dll/directx/wine/d3dx9_36/d3dx9_36.spec +++ b/dll/directx/wine/d3dx9_36/d3dx9_36.spec @@ -22,9 +22,9 @@ @ stdcall -stub D3DXComputeIMTFromPerVertexSignal(ptr ptr long long long ptr ptr ptr) @ stdcall -stub D3DXComputeIMTFromSignal(ptr long long long long ptr ptr ptr ptr ptr) @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) -@ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) +@ stdcall -stub D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -229,7 +229,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_36/d3dx9_36_private.h b/dll/directx/wine/d3dx9_36/d3dx9_36_private.h index 72b1c9d38df..ddc38225e0e 100644 --- a/dll/directx/wine/d3dx9_36/d3dx9_36_private.h +++ b/dll/directx/wine/d3dx9_36/d3dx9_36_private.h @@ -25,6 +25,7 @@ #include #include +#include #include #define WIN32_NO_STATUS diff --git a/dll/directx/wine/d3dx9_36/effect.c b/dll/directx/wine/d3dx9_36/effect.c index 039ab422327..7a5975a7061 100644 --- a/dll/directx/wine/d3dx9_36/effect.c +++ b/dll/directx/wine/d3dx9_36/effect.c @@ -20,7 +20,6 @@ #include "d3dx9_36_private.h" #include -#include /* Constants for special INT/FLOAT conversation */ #define INT_FLOAT_MULTI 255.0f @@ -100,6 +99,7 @@ struct d3dx_object UINT size; void *data; struct d3dx_parameter *param; + BOOL creation_failed; }; struct d3dx_state @@ -1140,21 +1140,17 @@ static HRESULT d3dx9_base_effect_get_pass_desc(struct d3dx9_base_effect *base, void *param_value; BOOL param_dirty; HRESULT hr; + void *data; if (FAILED(hr = d3dx9_get_param_value_ptr(pass, &pass->states[i], ¶m_value, ¶m, FALSE, ¶m_dirty))) return hr; - if (!param->object_id) - { - FIXME("Zero object ID in shader parameter.\n"); - return E_FAIL; - } - + data = param->object_id ? base->objects[param->object_id].data : NULL; if (state_table[state->operation].class == SC_VERTEXSHADER) - desc->pVertexShaderFunction = base->objects[param->object_id].data; + desc->pVertexShaderFunction = data; else - desc->pPixelShaderFunction = base->objects[param->object_id].data; + desc->pPixelShaderFunction = data; } } @@ -3938,48 +3934,59 @@ static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect *iface) static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique) { - struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface); + struct ID3DXEffectImpl *effect = impl_from_ID3DXEffect(iface); + struct d3dx9_base_effect *base = &effect->base_effect; + struct d3dx_technique *tech = get_valid_technique(base, technique); + HRESULT ret = D3D_OK; + unsigned int i, j; - FIXME("(%p)->(%p): stub\n", This, technique); + FIXME("iface %p, technique %p semi-stub.\n", iface, technique); - return D3D_OK; -} + if (!tech) + { + ret = D3DERR_INVALIDCALL; + goto done; + } + for (i = 0; i < tech->pass_count; ++i) + { + struct d3dx_pass *pass = &tech->passes[i]; -static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect *iface, - D3DXHANDLE technique, D3DXHANDLE *next_technique) -{ - struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface); - struct d3dx9_base_effect *base_effect = &This->base_effect; - UINT i = 0; + for (j = 0; j < pass->state_count; ++j) + { + struct d3dx_state *state = &pass->states[j]; - TRACE("iface %p, technique %p, next_technique %p\n", iface, technique, next_technique); + if (state_table[state->operation].class == SC_VERTEXSHADER + || state_table[state->operation].class == SC_PIXELSHADER) + { + struct d3dx_parameter *param; + void *param_value; + BOOL param_dirty; + HRESULT hr; - if (!next_technique) - return D3DERR_INVALIDCALL; + if (FAILED(hr = d3dx9_get_param_value_ptr(pass, &pass->states[j], ¶m_value, ¶m, + FALSE, ¶m_dirty))) + return hr; - if (technique) - { - for (; i < base_effect->technique_count; i++) - { - if (technique == get_technique_handle(&base_effect->techniques[i])) - { - i++; /* Go to next technique */ - break; + if (param->object_id && base->objects[param->object_id].creation_failed) + { + ret = E_FAIL; + goto done; + } } } } +done: + TRACE("Returning %#x.\n", ret); + return ret; +} - for (; i < base_effect->technique_count; i++) - { - if (SUCCEEDED(iface->lpVtbl->ValidateTechnique(iface, get_technique_handle(&base_effect->techniques[i])))) - { - *next_technique = get_technique_handle(&base_effect->techniques[i]); - return D3D_OK; - } - } +static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique) +{ + struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface); + + FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique); - *next_technique = NULL; - return S_FALSE; + return E_NOTIMPL; } static BOOL walk_parameter_dep(struct d3dx_parameter *param, walk_parameter_dep_func param_func, @@ -4340,7 +4347,6 @@ static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3 return E_NOTIMPL; } -#if _D3DX9_VER >= 26 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block) { struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface); @@ -4349,7 +4355,6 @@ static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D return E_NOTIMPL; } -#endif static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect *iface, struct IDirect3DDevice9 *device, struct ID3DXEffect **effect) @@ -4358,15 +4363,9 @@ static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect *iface, FIXME("(%p)->(%p, %p): stub\n", This, device, effect); - if (!effect) - return D3DXERR_INVALIDDATA; - - iface->lpVtbl->AddRef(iface); - *effect = iface; - return S_OK; + return E_NOTIMPL; } -#if _D3DX9_VER >= 27 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect *iface, D3DXHANDLE parameter, const void *data, UINT byte_offset, UINT bytes) { @@ -4375,7 +4374,6 @@ static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect *iface, return E_NOTIMPL; } -#endif static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl = { @@ -4458,13 +4456,9 @@ static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl = ID3DXEffectImpl_BeginParameterBlock, ID3DXEffectImpl_EndParameterBlock, ID3DXEffectImpl_ApplyParameterBlock, -#if _D3DX9_VER >= 26 ID3DXEffectImpl_DeleteParameterBlock, -#endif ID3DXEffectImpl_CloneEffect, -#if _D3DX9_VER >= 27 ID3DXEffectImpl_SetRawValue -#endif }; static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface) @@ -5976,7 +5970,7 @@ static HRESULT d3dx9_create_object(struct d3dx9_base_effect *base, struct d3dx_o (IDirect3DVertexShader9 **)param->data))) { WARN("Failed to create vertex shader.\n"); - return D3D_OK; + object->creation_failed = TRUE; } break; case D3DXPT_PIXELSHADER: @@ -5984,7 +5978,7 @@ static HRESULT d3dx9_create_object(struct d3dx9_base_effect *base, struct d3dx_o (IDirect3DPixelShader9 **)param->data))) { WARN("Failed to create pixel shader.\n"); - return D3D_OK; + object->creation_failed = TRUE; } break; default: @@ -6457,6 +6451,11 @@ static HRESULT d3dx9_base_effect_init(struct d3dx9_base_effect *base, char *skip_constants_buffer = NULL; const char **skip_constants = NULL; unsigned int skip_constants_count = 0; +#if D3DX_SDK_VERSION <= 36 + UINT compile_flags = D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY; +#else + UINT compile_flags = 0; +#endif unsigned int i, j; TRACE("base %p, data %p, data_size %lu, effect %p, pool %p, skip_constants %s.\n", @@ -6473,7 +6472,7 @@ static HRESULT d3dx9_base_effect_init(struct d3dx9_base_effect *base, { TRACE("HLSL ASCII effect, trying to compile it.\n"); hr = D3DCompile(data, data_size, NULL, defines, include, - "main", "fx_2_0", 0, eflags, &bytecode, &temp_errors); + "main", "fx_2_0", compile_flags, eflags, &bytecode, &temp_errors); if (FAILED(hr)) { WARN("Failed to compile ASCII effect.\n"); diff --git a/dll/directx/wine/d3dx9_36/font.c b/dll/directx/wine/d3dx9_36/font.c index 231cdb1790b..575e80d0bb7 100644 --- a/dll/directx/wine/d3dx9_36/font.c +++ b/dll/directx/wine/d3dx9_36/font.c @@ -29,29 +29,8 @@ struct d3dx_font HDC hdc; HFONT hfont; - - UINT tex_width; - UINT tex_height; - IDirect3DTexture9 *texture; - HBITMAP bitmap; - BYTE *bits; }; -/* Returns the smallest power of 2 which is greater than or equal to num */ -static UINT make_pow2(UINT num) -{ - UINT result = 1; - - /* In the unlikely event somebody passes a large value, make sure we don't enter an infinite loop */ - if (num >= 0x80000000) - return 0x80000000; - - while (result < num) - result <<= 1; - - return result; -} - static inline struct d3dx_font *impl_from_ID3DXFont(ID3DXFont *iface) { return CONTAINING_RECORD(iface, struct d3dx_font, ID3DXFont_iface); @@ -78,27 +57,19 @@ static HRESULT WINAPI ID3DXFontImpl_QueryInterface(ID3DXFont *iface, REFIID riid static ULONG WINAPI ID3DXFontImpl_AddRef(ID3DXFont *iface) { struct d3dx_font *This = impl_from_ID3DXFont(iface); - ULONG ref = InterlockedIncrement(&This->ref); - + ULONG ref=InterlockedIncrement(&This->ref); TRACE("%p increasing refcount to %u\n", iface, ref); - return ref; } static ULONG WINAPI ID3DXFontImpl_Release(ID3DXFont *iface) { struct d3dx_font *This = impl_from_ID3DXFont(iface); - ULONG ref = InterlockedDecrement(&This->ref); + ULONG ref=InterlockedDecrement(&This->ref); TRACE("%p decreasing refcount to %u\n", iface, ref); - if (!ref) - { - if (This->texture) - { - IDirect3DTexture9_Release(This->texture); - DeleteObject(This->bitmap); - } + if(ref==0) { DeleteObject(This->hfont); DeleteDC(This->hdc); IDirect3DDevice9_Release(This->device); @@ -201,187 +172,17 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadTextW(ID3DXFont *iface, const WCHAR * static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite, const char *string, INT count, RECT *rect, DWORD format, D3DCOLOR color) { - LPWSTR stringW; - INT countW, ret = 0; - - TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x\n", + FIXME("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x stub!\n", iface, sprite, debugstr_a(string), count, wine_dbgstr_rect(rect), format, color); - - if (!string || count == 0) - return 0; - - if (count < 0) - count = -1; - - countW = MultiByteToWideChar(CP_ACP, 0, string, count, NULL, 0); - stringW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR)); - if (stringW) - { - MultiByteToWideChar(CP_ACP, 0, string, count, stringW, countW); - ret = ID3DXFont_DrawTextW(iface, sprite, stringW, countW, rect, format, color); - HeapFree(GetProcessHeap(), 0, stringW); - } - - return ret; + return 1; } static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, const WCHAR *string, INT count, RECT *rect, DWORD format, D3DCOLOR color) { - struct d3dx_font *This = impl_from_ID3DXFont(iface); - RECT calc_rect; - INT height; - - TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x\n", + FIXME("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x stub!\n", iface, sprite, debugstr_w(string), count, wine_dbgstr_rect(rect), format, color); - - if (!string || count == 0) - return 0; - - if (count < 0) - count = lstrlenW(string); - - /* Strip terminating NULL characters */ - while (count > 0 && !string[count-1]) - count--; - - if (rect) - calc_rect = *rect; - - height = DrawTextW(This->hdc, string, count, &calc_rect, format | DT_CALCRECT); - - if (format & DT_CALCRECT) - { - if (rect) - *rect = calc_rect; - return height; - } - - if (format & DT_CENTER) - { - UINT new_width = calc_rect.right - calc_rect.left; - calc_rect.left = (rect->right + rect->left - new_width) / 2; - calc_rect.right = calc_rect.left + new_width; - } - - if (height && (calc_rect.left < calc_rect.right)) - { - D3DLOCKED_RECT locked_rect; - D3DXVECTOR3 position; - UINT text_width, text_height; - RECT text_rect; - ID3DXSprite *target = sprite; - HRESULT hr; - int i, j; - - /* Get rect position and dimensions */ - position.x = calc_rect.left; - position.y = calc_rect.top; - position.z = 0; - text_width = calc_rect.right - calc_rect.left; - text_height = calc_rect.bottom - calc_rect.top; - text_rect.left = 0; - text_rect.top = 0; - text_rect.right = text_width; - text_rect.bottom = text_height; - - /* We need to flush as it seems all draws in the begin/end sequence use only the latest updated texture */ - if (sprite) - ID3DXSprite_Flush(sprite); - - /* Extend texture and DIB section to contain text */ - if ((text_width > This->tex_width) || (text_height > This->tex_height)) - { - BITMAPINFOHEADER header; - - if (text_width > This->tex_width) - This->tex_width = make_pow2(text_width); - if (text_height > This->tex_height) - This->tex_height = make_pow2(text_height); - - if (This->texture) - { - IDirect3DTexture9_Release(This->texture); - DeleteObject(This->bitmap); - } - - hr = D3DXCreateTexture(This->device, This->tex_width, This->tex_height, 1, 0, - D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &This->texture); - if (FAILED(hr)) - { - This->texture = NULL; - return 0; - } - - header.biSize = sizeof(header); - header.biWidth = This->tex_width; - header.biHeight = -This->tex_height; - header.biPlanes = 1; - header.biBitCount = 32; - header.biCompression = BI_RGB; - header.biSizeImage = sizeof(DWORD) * This->tex_width * This->tex_height; - header.biXPelsPerMeter = 0; - header.biYPelsPerMeter = 0; - header.biClrUsed = 0; - header.biClrImportant = 0; - - This->bitmap = CreateDIBSection(This->hdc, (const BITMAPINFO*)&header, - DIB_RGB_COLORS, (void**)&This->bits, NULL, 0); - if (!This->bitmap) - { - IDirect3DTexture9_Release(This->texture); - This->texture = NULL; - return 0; - } - - SelectObject(This->hdc, This->bitmap); - } - - if (FAILED(IDirect3DTexture9_LockRect(This->texture, 0, &locked_rect, &text_rect, D3DLOCK_DISCARD))) - return 0; - - /* Clear rect */ - for (i = 0; i < text_height; i++) - memset(This->bits + i * This->tex_width * sizeof(DWORD), 0, - text_width * sizeof(DWORD)); - - DrawTextW(This->hdc, string, count, &text_rect, format); - - /* All RGB components are equal so take one as alpha and set RGB - * color to white, so it can be modulated with color parameter */ - for (i = 0; i < text_height; i++) - { - DWORD *src = (DWORD *)This->bits + i * This->tex_width; - DWORD *dst = (DWORD *)((BYTE *)locked_rect.pBits + i * locked_rect.Pitch); - for (j = 0; j < text_width; j++) - { - *dst++ = (*src++ << 24) | 0xFFFFFF; - } - } - - IDirect3DTexture9_UnlockRect(This->texture, 0); - - if (!sprite) - { - hr = D3DXCreateSprite(This->device, &target); - if (FAILED(hr)) - return 0; - ID3DXSprite_Begin(target, 0); - } - - hr = target->lpVtbl->Draw(target, This->texture, &text_rect, NULL, &position, color); - - if (!sprite) - { - ID3DXSprite_End(target); - ID3DXSprite_Release(target); - } - - if (FAILED(hr)) - return 0; - } - - return height; + return 1; } static HRESULT WINAPI ID3DXFontImpl_OnLostDevice(ID3DXFont *iface) @@ -495,55 +296,46 @@ HRESULT WINAPI D3DXCreateFontIndirectW(IDirect3DDevice9 *device, const D3DXFONT_ TRACE("(%p, %p, %p)\n", device, desc, font); - if (!device || !desc || !font) return D3DERR_INVALIDCALL; - - TRACE("desc: %d %d %d %d %d %d %d %d %d %s\n", desc->Height, desc->Width, desc->Weight, desc->MipLevels, desc->Italic, - desc->CharSet, desc->OutputPrecision, desc->Quality, desc->PitchAndFamily, debugstr_w(desc->FaceName)); + if( !device || !desc || !font ) return D3DERR_INVALIDCALL; - /* The device MUST support D3DFMT_A8R8G8B8 */ + /* the device MUST support D3DFMT_A8R8G8B8 */ IDirect3DDevice9_GetDirect3D(device, &d3d); IDirect3DDevice9_GetCreationParameters(device, &cpars); IDirect3DDevice9_GetDisplayMode(device, 0, &mode); hr = IDirect3D9_CheckDeviceFormat(d3d, cpars.AdapterOrdinal, cpars.DeviceType, mode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_A8R8G8B8); - if (FAILED(hr)) - { + if(FAILED(hr)) { IDirect3D9_Release(d3d); return D3DXERR_INVALIDDATA; } IDirect3D9_Release(d3d); - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct d3dx_font)); - if (!object) - { - *font = NULL; + object = HeapAlloc(GetProcessHeap(), 0, sizeof(struct d3dx_font)); + if(object==NULL) { + *font=NULL; return E_OUTOFMEMORY; } object->ID3DXFont_iface.lpVtbl = &D3DXFont_Vtbl; - object->ref = 1; - object->device = device; - object->desc = *desc; + object->ref=1; + object->device=device; + object->desc=*desc; object->hdc = CreateCompatibleDC(NULL); - if (!object->hdc) - { + if( !object->hdc ) { HeapFree(GetProcessHeap(), 0, object); return D3DXERR_INVALIDDATA; } object->hfont = CreateFontW(desc->Height, desc->Width, 0, 0, desc->Weight, desc->Italic, FALSE, FALSE, desc->CharSet, desc->OutputPrecision, CLIP_DEFAULT_PRECIS, desc->Quality, desc->PitchAndFamily, desc->FaceName); - if (!object->hfont) - { + if( !object->hfont ) { DeleteDC(object->hdc); HeapFree(GetProcessHeap(), 0, object); return D3DXERR_INVALIDDATA; } SelectObject(object->hdc, object->hfont); - SetTextColor(object->hdc, 0x00ffffff); - SetBkColor(object->hdc, 0x00000000); IDirect3DDevice9_AddRef(device); - *font = &object->ID3DXFont_iface; + *font=&object->ID3DXFont_iface; return D3D_OK; } diff --git a/dll/directx/wine/d3dx9_36/mesh.c b/dll/directx/wine/d3dx9_36/mesh.c index 2f9615eed43..57b2aeb1a18 100644 --- a/dll/directx/wine/d3dx9_36/mesh.c +++ b/dll/directx/wine/d3dx9_36/mesh.c @@ -26,13 +26,10 @@ #include "d3dx9_36_private.h" -#include #ifdef HAVE_FLOAT_H # include #endif -#undef MAKE_DDHRESULT -#include "dxfile.h" #include "rmxfguid.h" #include "rmxftmpl.h" @@ -1691,7 +1688,11 @@ static HRESULT WINAPI d3dx9_mesh_OptimizeInplace(ID3DXMesh *iface, DWORD flags, if (FAILED(hr)) goto cleanup; } else if (flags & D3DXMESHOPT_ATTRSORT) { if (!(flags & D3DXMESHOPT_IGNOREVERTS)) + { FIXME("D3DXMESHOPT_ATTRSORT vertex reordering not implemented.\n"); + hr = E_NOTIMPL; + goto cleanup; + } hr = iface->lpVtbl->LockAttributeBuffer(iface, 0, &attrib_buffer); if (FAILED(hr)) goto cleanup; @@ -3324,13 +3325,6 @@ static HRESULT parse_mesh(ID3DXFileData *filedata, struct mesh_data *mesh_data, goto end; } - if ((provide_flags & PROVIDE_SKININFO) && !mesh_data->skin_info) - { - hr = create_dummy_skin(&mesh_data->skin_info); - if (FAILED(hr)) - goto end; - } - hr = D3D_OK; end: @@ -4045,12 +4039,6 @@ HRESULT WINAPI D3DXFrameDestroy(D3DXFRAME *frame, ID3DXAllocateHierarchy *alloc_ return D3D_OK; } -D3DXFRAME* WINAPI D3DXFrameFind(const D3DXFRAME *frame_root, const char *name) -{ - FIXME("frame_root %p, name %s stub.\n", frame_root, debugstr_a(name)); - return NULL; -} - HRESULT WINAPI D3DXLoadMeshFromXA(const char *filename, DWORD options, struct IDirect3DDevice9 *device, struct ID3DXBuffer **adjacency, struct ID3DXBuffer **materials, struct ID3DXBuffer **effect_instances, DWORD *num_materials, struct ID3DXMesh **mesh) @@ -5171,7 +5159,7 @@ HRESULT WINAPI D3DXCreateTeapot(struct IDirect3DDevice9 *device, { FIXME("(%p, %p, %p): stub\n", device, mesh, adjacency); - return D3DXCreateSphere(device, 1.0f, 4, 4, mesh, adjacency); + return E_NOTIMPL; } HRESULT WINAPI D3DXCreateTextA(struct IDirect3DDevice9 *device, HDC hdc, const char *text, float deviation, @@ -7189,33 +7177,6 @@ cleanup: return hr; } - -/************************************************************************* - * D3DXOptimizeVertices (D3DX9_36.@) - */ -HRESULT WINAPI D3DXOptimizeVertices(const void *indices, UINT num_faces, - UINT num_vertices, BOOL indices_are_32bit, DWORD *vertex_remap) -{ - UINT i; - - FIXME("indices %p, num_faces %u, num_vertices %u, indices_are_32bit %#x, vertex_remap %p semi-stub.\n", - indices, num_faces, num_vertices, indices_are_32bit, vertex_remap); - - if (!vertex_remap) - { - WARN("vertex remap pointer is NULL.\n"); - return D3DERR_INVALIDCALL; - } - - for (i = 0; i < num_vertices; i++) - { - vertex_remap[i] = i; - } - - return D3D_OK; -} - - /************************************************************************* * D3DXOptimizeFaces (D3DX9_36.@) * @@ -7539,24 +7500,6 @@ done: return hr; } -/************************************************************************* - * D3DXComputeTangent (D3DX9_36.@) - */ -HRESULT WINAPI D3DXComputeTangent(ID3DXMesh *mesh, DWORD stage_idx, DWORD tangent_idx, - DWORD binorm_idx, DWORD wrap, const DWORD *adjacency) -{ - TRACE("mesh %p, stage_idx %d, tangent_idx %d, binorm_idx %d, wrap %d, adjacency %p.\n", - mesh, stage_idx, tangent_idx, binorm_idx, wrap, adjacency); - - return D3DXComputeTangentFrameEx( mesh, D3DDECLUSAGE_TEXCOORD, stage_idx, - ( binorm_idx == D3DX_DEFAULT ) ? D3DX_DEFAULT : D3DDECLUSAGE_BINORMAL, - binorm_idx, - ( tangent_idx == D3DX_DEFAULT ) ? D3DX_DEFAULT : D3DDECLUSAGE_TANGENT, - tangent_idx, D3DX_DEFAULT, 0, - ( wrap ? D3DXTANGENT_WRAP_UV : 0 ) | D3DXTANGENT_GENERATE_IN_PLACE | D3DXTANGENT_ORTHOGONALIZE_FROM_U, - adjacency, -1.01f, -0.01f, -1.01f, NULL, NULL); -} - /************************************************************************* * D3DXComputeNormals (D3DX9_36.@) */ @@ -7576,18 +7519,6 @@ HRESULT WINAPI D3DXComputeNormals(struct ID3DXBaseMesh *mesh, const DWORD *adjac adjacency, -1.01f, -0.01f, -1.01f, NULL, NULL); } -/************************************************************************* - * D3DXComputeNormalMap (D3DX9_36.@) - */ -HRESULT WINAPI D3DXComputeNormalMap(IDirect3DTexture9 *texture, IDirect3DTexture9 *src_texture, - const PALETTEENTRY *src_palette, DWORD flags, DWORD channel, FLOAT amplitude) -{ - FIXME("texture %p, src_texture %p, src_palette %p, flags %#x, channel %u, amplitude %f stub.\n", - texture, src_texture, src_palette, flags, channel, amplitude); - - return D3D_OK; -} - /************************************************************************* * D3DXIntersect (D3DX9_36.@) */ @@ -7617,3 +7548,83 @@ HRESULT WINAPI D3DXConvertMeshSubsetToSingleStrip(struct ID3DXBaseMesh *mesh_in, return E_NOTIMPL; } + +struct frame_node +{ + struct list entry; + D3DXFRAME *frame; +}; + +static BOOL queue_frame_node(struct list *queue, D3DXFRAME *frame) +{ + struct frame_node *node; + + if (!frame->pFrameFirstChild) + return TRUE; + + node = HeapAlloc(GetProcessHeap(), 0, sizeof(*node)); + if (!node) + return FALSE; + + node->frame = frame; + list_add_tail(queue, &node->entry); + + return TRUE; +} + +static void empty_frame_queue(struct list *queue) +{ + struct frame_node *cur, *cur2; + LIST_FOR_EACH_ENTRY_SAFE(cur, cur2, queue, struct frame_node, entry) + { + list_remove(&cur->entry); + HeapFree(GetProcessHeap(), 0, cur); + } +} + +D3DXFRAME * WINAPI D3DXFrameFind(const D3DXFRAME *root, const char *name) +{ + D3DXFRAME *found = NULL, *frame; + struct list queue; + + TRACE("root frame %p, name %s.\n", root, debugstr_a(name)); + + if (!root) + return NULL; + + list_init(&queue); + + frame = (D3DXFRAME *)root; + + for (;;) + { + struct frame_node *node; + + while (frame) + { + if ((name && frame->Name && !strcmp(frame->Name, name)) || (!name && !frame->Name)) + { + found = frame; + goto cleanup; + } + + if (!queue_frame_node(&queue, frame)) + goto cleanup; + + frame = frame->pFrameSibling; + } + + if (list_empty(&queue)) + break; + + node = LIST_ENTRY(list_head(&queue), struct frame_node, entry); + list_remove(&node->entry); + frame = node->frame->pFrameFirstChild; + HeapFree(GetProcessHeap(), 0, node); + } + +cleanup: + empty_frame_queue(&queue); + + return found; +} diff --git a/dll/directx/wine/d3dx9_36/preshader.c b/dll/directx/wine/d3dx9_36/preshader.c index a8a58589502..416f05b15a2 100644 --- a/dll/directx/wine/d3dx9_36/preshader.c +++ b/dll/directx/wine/d3dx9_36/preshader.c @@ -18,8 +18,6 @@ #include "d3dx9_36_private.h" -#include - /* ReactOS FIXME: Insect */ #define fmin min #define fmax max @@ -537,6 +535,8 @@ static HRESULT get_ctab_constant_desc(ID3DXConstantTable *ctab, D3DXHANDLE hc, D if (!constant) { FIXME("Could not get constant desc.\n"); + if (constantinfo_reserved) + *constantinfo_reserved = 0; return D3DERR_INVALIDCALL; } *desc = constant->desc; diff --git a/dll/directx/wine/d3dx9_36/shader.c b/dll/directx/wine/d3dx9_36/shader.c index 71c01224814..48e49a29824 100644 --- a/dll/directx/wine/d3dx9_36/shader.c +++ b/dll/directx/wine/d3dx9_36/shader.c @@ -1,7 +1,6 @@ /* * Copyright 2008 Luis Busquets * Copyright 2009 Matteo Bruni - * Copyright 2010, 2013, 2016 Christian Costa * Copyright 2011 Travis Athougies * * This library is free software; you can redistribute it and/or @@ -441,41 +440,6 @@ HRESULT WINAPI D3DXCompileShader(const char *data, UINT length, const D3DXMACRO } } - /* Filter out D3DCompile warning messages that are not present with D3DCompileShader */ - if (SUCCEEDED(hr) && error_msgs && *error_msgs) - { - char *messages = ID3DXBuffer_GetBufferPointer(*error_msgs); - DWORD size = ID3DXBuffer_GetBufferSize(*error_msgs); - - /* Ensure messages are null terminated for safe processing */ - if (size) messages[size - 1] = 0; - - while (size > 1) - { - char *prev, *next; - - /* Warning has the form "warning X3206: ... implicit truncation of vector type" - but we only search for "X3206:" in case d3dcompiler_43 has localization */ - prev = next = strstr(messages, "X3206:"); - if (!prev) break; - - /* get pointer to beginning and end of current line */ - while (prev > messages && *(prev - 1) != '\n') prev--; - while (next < messages + size - 1 && *next != '\n') next++; - if (next < messages + size - 1 && *next == '\n') next++; - - memmove(prev, next, messages + size - next); - size -= (next - prev); - } - - /* Only return a buffer if the resulting string is not empty as some apps depend on that */ - if (size <= 1) - { - ID3DXBuffer_Release(*error_msgs); - *error_msgs = NULL; - } - } - return hr; } @@ -2177,334 +2141,10 @@ HRESULT WINAPI D3DXGetShaderSamplers(const DWORD *byte_code, const char **sample return D3D_OK; } - -static const char *decl_usage[] = { "position", "blendweight", "blendindices", "normal", "psize", "texcoord", - "tangent", "binormal", "tessfactor", "positiont", "color" }; - -static const char *tex_type[] = { "", "1d", "2d", "cube", "volume" }; - -static int add_modifier(char *buffer, DWORD param) -{ - char *buf = buffer; - DWORD dst_mod = param & D3DSP_DSTMOD_MASK; - - if (dst_mod & D3DSPDM_SATURATE) - buf += sprintf(buf, "_sat"); - if (dst_mod & D3DSPDM_PARTIALPRECISION) - buf += sprintf(buf, "_pp"); - if (dst_mod & D3DSPDM_MSAMPCENTROID) - buf += sprintf(buf, "_centroid"); - - return buf - buffer; -} - -static int add_register(char *buffer, DWORD param, BOOL dst, BOOL ps) -{ - char *buf = buffer; - DWORD reg_type = ((param & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2) - | ((param & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT); - DWORD reg_num = param & D3DSP_REGNUM_MASK; - - if (reg_type == D3DSPR_INPUT) - buf += sprintf(buf, "v%d", reg_num); - else if (reg_type == D3DSPR_CONST) - buf += sprintf(buf, "c%d", reg_num); - else if (reg_type == D3DSPR_TEMP) - buf += sprintf(buf, "r%d", reg_num); - else if (reg_type == D3DSPR_ADDR) - buf += sprintf(buf, "%s%d", ps ? "t" : "a", reg_num); - else if (reg_type == D3DSPR_SAMPLER) - buf += sprintf(buf, "s%d", reg_num); - else if (reg_type == D3DSPR_RASTOUT) - buf += sprintf(buf, "oPos"); - else if (reg_type == D3DSPR_COLOROUT) - buf += sprintf(buf, "oC%d", reg_num); - else if (reg_type == D3DSPR_TEXCRDOUT) - buf += sprintf(buf, "oT%d", reg_num); - else if (reg_type == D3DSPR_ATTROUT) - buf += sprintf(buf, "oD%d", reg_num); - else - buf += sprintf(buf, "? (%d)", reg_type); - - if (dst) - { - if ((param & D3DSP_WRITEMASK_ALL) != D3DSP_WRITEMASK_ALL) - { - buf += sprintf(buf, ".%s%s%s%s", param & D3DSP_WRITEMASK_0 ? "x" : "", - param & D3DSP_WRITEMASK_1 ? "y" : "", - param & D3DSP_WRITEMASK_2 ? "z" : "", - param & D3DSP_WRITEMASK_3 ? "w" : ""); - } - } - else - { - if ((param & D3DVS_SWIZZLE_MASK) != D3DVS_NOSWIZZLE) - { - if ( ((param & D3DSP_SWIZZLE_MASK) == (D3DVS_X_X | D3DVS_Y_X | D3DVS_Z_X | D3DVS_W_X)) || - ((param & D3DSP_SWIZZLE_MASK) == (D3DVS_X_Y | D3DVS_Y_Y | D3DVS_Z_Y | D3DVS_W_Y)) || - ((param & D3DSP_SWIZZLE_MASK) == (D3DVS_X_Z | D3DVS_Y_Z | D3DVS_Z_Z | D3DVS_W_Z)) || - ((param & D3DSP_SWIZZLE_MASK) == (D3DVS_X_W | D3DVS_Y_W | D3DVS_Z_W | D3DVS_W_W)) ) - buf += sprintf(buf, ".%c", 'w' + (((param >> D3DVS_SWIZZLE_SHIFT) + 1) & 0x3)); - else - buf += sprintf(buf, ".%c%c%c%c", 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+0)) + 1) & 0x3), - 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+2)) + 1) & 0x3), - 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+4)) + 1) & 0x3), - 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+6)) + 1) & 0x3)); - } - } - - return buf - buffer; -} - -struct instr_info -{ - DWORD opcode; - const char *name; - int length; - int (*function)(const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps); - WORD min_version; - WORD max_version; -}; - -static int instr_comment(const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps) -{ - *ptr += 1 + ((**ptr & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT); - return 0; -} - -static int instr_def(const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps) -{ - int len = sprintf(buffer, " def c%d, %g, %g, %g, %g\n", *(*ptr+1) & D3DSP_REGNUM_MASK, - (double)*(float*)(*ptr+2), (double)*(float*)(*ptr+3), - (double)*(float*)(*ptr+4), (double)*(float*)(*ptr+5)); - *ptr += 6; - return len; -} - -static int instr_dcl(const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps) -{ - DWORD param1 = *++*ptr; - DWORD param2 = *++*ptr; - DWORD usage = (param1 & D3DSP_DCL_USAGE_MASK) >> D3DSP_DCL_USAGE_SHIFT; - DWORD usage_index = (param1 & D3DSP_DCL_USAGEINDEX_MASK) >> D3DSP_DCL_USAGEINDEX_SHIFT; - char *buf = buffer; - - buf += sprintf(buf, " dcl"); - if (ps) - { - if (param1 & D3DSP_TEXTURETYPE_MASK) - buf += sprintf(buf, "_%s", (usage <= D3DSTT_VOLUME) ? - tex_type[(param1 & D3DSP_TEXTURETYPE_MASK) >> D3DSP_TEXTURETYPE_SHIFT] : "???"); - } - else - { - buf += sprintf(buf, "_%s", (usage <= D3DDECLUSAGE_COLOR) ? decl_usage[usage] : "???"); - if (usage_index) - buf += sprintf(buf, "%d", usage_index); - } - - buf += add_modifier(buf, param2); - buf += sprintf(buf, " "); - buf += add_register(buf, param2, TRUE, TRUE); - buf += sprintf(buf, "\n"); - (*ptr)++; - return buf - buffer; -} - -static int instr_generic(const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps) -{ - char *buf = buffer; - int j; - - buf += sprintf(buf, " %s", info->name); - (*ptr)++; - - if (info->length) - { - buf += add_modifier(buf, **ptr); - - for (j = 0; j < info->length; j++) - { - buf += sprintf(buf, "%s ", j ? "," : ""); - - if ((j != 0) && ((**ptr & D3DSP_SRCMOD_MASK) != D3DSPSM_NONE)) - { - if ((**ptr & D3DSP_SRCMOD_MASK) == D3DSPSM_NEG) - buf += sprintf(buf, "-"); - else - buf += sprintf(buf, "*"); - } - - buf += add_register(buf, **ptr, j == 0, ps); - - if (*(*ptr)++ & D3DVS_ADDRESSMODE_MASK) - { - buf += sprintf(buf, "["); - buf += add_register(buf, **ptr, FALSE, FALSE); - buf += sprintf(buf, "]"); - (*ptr)++; - } - } - } - buf += sprintf(buf, "\n"); - return buf - buffer; -} - -const struct instr_info instructions[] = -{ - { D3DSIO_NOP, "nop", 0, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_MOV, "mov", 2, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_ADD, "add", 3, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_SUB, "sub", 3, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_MAD, "mad", 4, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_MUL, "mul", 3, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_RCP, "rcp", 2, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_RSQ, "rsq", 2, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_DP3, "dp3", 3, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_DP4, "dp4", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 1.2 for PS */ - { D3DSIO_MIN, "min", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_MAX, "max", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_SLT, "slt", 3, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_SGE, "sge", 3, instr_generic, 0x0100, 0xFFFF }, /* VS only */ - { D3DSIO_EXP, "exp", 2, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_LOG, "log", 2, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_LIT, "lit", 2, instr_generic, 0x0100, 0xFFFF }, /* VS only */ - { D3DSIO_DST, "dst", 3, instr_generic, 0x0100, 0xFFFF }, /* VS only */ - { D3DSIO_LRP, "lrp", 4, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for VS */ - { D3DSIO_FRC, "frc", 2, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_M4x4, "m4x4", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_M4x3, "m4x3", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_M3x4, "m3x4", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_M3x3, "m3x3", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_M3x2, "m3x2", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_CALL, "call", 1, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_CALLNZ, "callnz", 2, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_LOOP, "loop", 2, instr_generic, 0x0200, 0xFFFF }, /* >= 3.0 for PS */ - { D3DSIO_RET, "ret", 0, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_ENDLOOP, "endloop", 1, instr_generic, 0x0200, 0xFFFF }, /* >= 3.0 for PS */ - { D3DSIO_LABEL, "label", 1, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_DCL, "dcl", 1, instr_dcl, 0x0100, 0xFFFF }, - { D3DSIO_POW, "pow", 3, instr_generic, 0x0200, 0xFFFF }, - { D3DSIO_CRS, "crs", 3, instr_generic, 0x0200, 0xFFFF }, - { D3DSIO_SGN, "sgn", 4, instr_generic, 0x0200, 0xFFFF }, /* VS only */ - { D3DSIO_ABS, "abs", 2, instr_generic, 0x0200, 0xFFFF }, - { D3DSIO_NRM, "nrm", 2, instr_generic, 0x0200, 0xFFFF }, - { D3DSIO_SINCOS, "sincos", 4, instr_generic, 0x0200, 0x02FF }, - { D3DSIO_SINCOS, "sincos", 2, instr_generic, 0x0300, 0xFFFF }, - { D3DSIO_REP, "rep", 1, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_ENDREP, "endrep", 0, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_IF, "if", 1, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_IFC, "if_comp", 2, instr_generic, 0x0200, 0xFFFF }, - { D3DSIO_ELSE, "else", 0, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_ENDIF, "endif", 0, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_BREAK, "break", 0, instr_generic, 0x0201, 0xFFFF }, - { D3DSIO_BREAKC, "break_comp", 2, instr_generic, 0x0201, 0xFFFF }, - { D3DSIO_MOVA, "mova", 2, instr_generic, 0x0200, 0xFFFF }, /* VS only */ - { D3DSIO_DEFB, "defb", 2, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_DEFI, "defi", 2, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_TEXCOORD, "texcoord", 1, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXCOORD, "texcrd", 2, instr_generic, 0x0104, 0x0104 }, /* PS only */ - { D3DSIO_TEXKILL, "texkill", 1, instr_generic, 0x0100, 0xFFFF }, /* PS only */ - { D3DSIO_TEX, "tex", 1, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEX, "texld", 2, instr_generic, 0x0104, 0x0104 }, /* PS only */ - { D3DSIO_TEX, "texld", 3, instr_generic, 0x0200, 0xFFFF }, /* PS only */ - { D3DSIO_TEXBEM, "texbem", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXBEML, "texbeml", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXREG2AR, "texreg2ar", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXREG2GB, "texreg2gb", 2, instr_generic, 0x0102, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x2PAD, "texm3x2pad", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x2TEX, "texm3x2tex", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x3PAD, "texm3x3pad", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x3TEX, "texm3x3tex", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x3DIFF, "texm3x3diff", 2, instr_generic, 0x0100, 0xFFFF }, /* PS only - Not documented */ - { D3DSIO_TEXM3x3SPEC, "texm3x3spec", 3, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x3VSPEC, "texm3x3vspec", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_EXPP, "expp", 2, instr_generic, 0x0100, 0xFFFF }, /* VS only */ - { D3DSIO_LOGP, "logp", 2, instr_generic, 0x0100, 0xFFFF }, /* VS only */ - { D3DSIO_CND, "cnd", 4, instr_generic, 0x0100, 0x0104 }, /* PS only */ - { D3DSIO_DEF, "def", 5, instr_def, 0x0100, 0xFFFF }, - { D3DSIO_TEXREG2RGB, "texreg2rgb", 2, instr_generic, 0x0102, 0x0103 }, /* PS only */ - { D3DSIO_TEXDP3TEX, "texdp3tex", 2, instr_generic, 0x0102, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x2DEPTH, "texm3x2depth", 2, instr_generic, 0x0103, 0x0103 }, /* PS only */ - { D3DSIO_TEXDP3, "texdp3", 2, instr_generic, 0x0102, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x3, "texm3x3", 2, instr_generic, 0x0102, 0x0103 }, /* PS only */ - { D3DSIO_TEXDEPTH, "texdepth", 1, instr_generic, 0x0104, 0x0104 }, /* PS only */ - { D3DSIO_CMP, "cmp", 4, instr_generic, 0x0102, 0xFFFF }, /* PS only */ - { D3DSIO_BEM, "bem", 3, instr_generic, 0x0104, 0x0104 }, /* PS only */ - { D3DSIO_DP2ADD, "dp2add", 4, instr_generic, 0x0200, 0xFFFF }, /* PS only */ - { D3DSIO_DSX, "dsx", 2, instr_generic, 0x0201, 0xFFFF }, /* PS only */ - { D3DSIO_DSY, "dsy", 2, instr_generic, 0x0201, 0xFFFF }, /* PS only */ - { D3DSIO_TEXLDD, "texldd", 5, instr_generic, 0x0201, 0xFFFF }, /* PS only - not existing for 2.b */ - { D3DSIO_SETP, "setp_comp", 3, instr_generic, 0x0201, 0xFFFF }, - { D3DSIO_TEXLDL, "texldl", 3, instr_generic, 0x0300, 0xFFFF }, - { D3DSIO_BREAKP, "breakp", 1, instr_generic, 0x0201, 0xFFFF }, - { D3DSIO_PHASE, "phase", 0, instr_generic, 0x0104, 0x0104 }, /* PS only */ - { D3DSIO_COMMENT, "", 0, instr_comment, 0x0100, 0xFFFF } -}; - HRESULT WINAPI D3DXDisassembleShader(const DWORD *shader, BOOL colorcode, const char *comments, ID3DXBuffer **disassembly) { - DWORD *ptr = (DWORD *)shader; - char *buffer, *buf; - UINT capacity = 4096; - BOOL ps; - WORD version; - HRESULT hr; - - TRACE("%p %d %s %p\n", shader, colorcode, debugstr_a(comments), disassembly); - - if (!shader || !disassembly) - return D3DERR_INVALIDCALL; - - buf = buffer = HeapAlloc(GetProcessHeap(), 0, capacity); - if (!buffer) - return E_OUTOFMEMORY; - - ps = (*ptr >> 16) & 1; - version = *ptr & 0xFFFF; - buf += sprintf(buf, " %s_%d_%d\n", ps ? "ps" : "vs", D3DSHADER_VERSION_MAJOR(*ptr), D3DSHADER_VERSION_MINOR(*ptr)); - ptr++; - - while (*ptr != D3DSIO_END) - { - DWORD index; - - if ((buf - buffer + 128) > capacity) - { - UINT count = buf - buffer; - char *new_buffer = HeapReAlloc(GetProcessHeap(), 0, buffer, capacity * 2); - if (!new_buffer) - { - HeapFree(GetProcessHeap(), 0, buffer); - return E_OUTOFMEMORY; - } - capacity *= 2; - buffer = new_buffer; - buf = buffer + count; - } - - for (index = 0; index < sizeof(instructions)/sizeof(instructions[0]); index++) - if (((*ptr & D3DSI_OPCODE_MASK) == instructions[index].opcode) && - (version >= instructions[index].min_version) && (version <= instructions[index].max_version)) - break; - - if (index != sizeof(instructions)/sizeof(instructions[0])) - { - buf += instructions[index].function(&(instructions[index]), &ptr, buf, ps); - } - else - { - buf += sprintf(buf, " ??? (Unknown opcode %x)\n", *ptr); - while (*++ptr & (1u << 31)); - } - } - - hr = D3DXCreateBuffer(buf - buffer + 1 , disassembly); - if (SUCCEEDED(hr)) - strcpy(ID3DXBuffer_GetBufferPointer(*disassembly), buffer); - HeapFree(GetProcessHeap(), 0, buffer); - - return hr; + FIXME("%p %d %s %p: stub\n", shader, colorcode, debugstr_a(comments), disassembly); + return E_OUTOFMEMORY; } struct d3dx9_texture_shader @@ -2774,112 +2414,248 @@ HRESULT WINAPI D3DXCreateTextureShader(const DWORD *function, ID3DXTextureShader return D3D_OK; } -static const DWORD* skip_instruction(const DWORD *byte_code, UINT shader_model) +static unsigned int get_instr_length(const DWORD *byte_code, unsigned int major, unsigned int minor) { - TRACE("Shader model %u\n", shader_model); + unsigned int len = 0; - /* Handle all special instructions whose arguments may contain D3DSIO_DCL */ - if ((*byte_code & D3DSI_OPCODE_MASK) == D3DSIO_COMMENT) - { - byte_code += 1 + ((*byte_code & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT); - } - else if (shader_model >= 2) - { - byte_code += 1 + ((*byte_code & D3DSI_INSTLENGTH_MASK) >> D3DSI_INSTLENGTH_SHIFT); - } - else if ((*byte_code & D3DSI_OPCODE_MASK) == D3DSIO_DEF) - { - byte_code += 1 + 5; - } - else + if (major > 1) + return (*byte_code & D3DSI_INSTLENGTH_MASK) >> D3DSI_INSTLENGTH_SHIFT; + + switch (*byte_code & 0xffff) { - /* Handle remaining safe instructions */ - while (*++byte_code & (1u << 31)); + case D3DSIO_END: + ERR("Unexpected END token.\n"); + return 0; + case D3DSIO_COMMENT: + return (*byte_code & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT; + case D3DSIO_DEF: + case D3DSIO_DEFI: + return 5; + case D3DSIO_DEFB: + return 2; + default: + ++byte_code; + while (*byte_code & 0x80000000) + { + ++byte_code; + ++len; + } } - return byte_code; + return len; } -static UINT get_shader_semantics(const DWORD *byte_code, D3DXSEMANTIC *semantics, DWORD type) -{ - const DWORD *ptr = byte_code; - UINT shader_model = (*ptr >> 8) & 0xff; - UINT i = 0; +static HRESULT get_shader_semantics(const DWORD *byte_code, D3DXSEMANTIC *semantics, UINT *count, BOOL output) +{ + static const D3DDECLUSAGE regtype_usage[] = + { + D3DDECLUSAGE_COLOR, + D3DDECLUSAGE_COLOR, + 0, + D3DDECLUSAGE_TEXCOORD, + 0, + D3DDECLUSAGE_COLOR, + D3DDECLUSAGE_TEXCOORD, + 0, + 0, + D3DDECLUSAGE_DEPTH + }; + static const D3DDECLUSAGE rast_usage[] = + { + D3DDECLUSAGE_POSITION, + D3DDECLUSAGE_FOG, + D3DDECLUSAGE_PSIZE + }; + DWORD reg_type, usage, index, version_token = *byte_code; + BOOL is_ps = version_token >> 16 == 0xffff; + unsigned int major, minor, i = 0, j; + BYTE colors = 0, rastout = 0; + BOOL has_dcl, depth = 0; + WORD texcoords = 0; + + if ((version_token & 0xffff0000) != 0xfffe0000 && (version_token & 0xffff0000) != 0xffff0000) + return D3DXERR_INVALIDDATA; + + major = version_token >> 8 & 0xff; + minor = version_token & 0xff; - TRACE("Shader version: %#x\n", *ptr); - ptr++; + TRACE("%s shader, version %u.%u.\n", is_ps ? "Pixel" : "Vertex", major, minor); + ++byte_code; - while (*ptr != D3DSIO_END) + has_dcl = (!is_ps && (!output || major == 3)) || (is_ps && !output && major >= 2); + + while (*byte_code != D3DSIO_END) { - if (*ptr & (1u << 31)) - { - FIXME("Opcode expected but got %#x\n", *ptr); - return 0; - } - else if ((*ptr & D3DSI_OPCODE_MASK) == D3DSIO_DCL) + if (has_dcl && (*byte_code & 0xffff) == D3DSIO_DCL) { - DWORD param1 = *++ptr; - DWORD param2 = *++ptr; - DWORD usage = (param1 & D3DSP_DCL_USAGE_MASK) >> D3DSP_DCL_USAGE_SHIFT; - DWORD usage_index = (param1 & D3DSP_DCL_USAGEINDEX_MASK) >> D3DSP_DCL_USAGEINDEX_SHIFT; - DWORD reg_type = ((param2 & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2) - | ((param2 & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT); + DWORD usage_token = byte_code[1]; + DWORD reg = byte_code[2]; - TRACE("D3DSIO_DCL param1: %#x, param2: %#x, usage: %u, usage_index: %u, reg_type: %u\n", - param1, param2, usage, usage_index, reg_type); + reg_type = ((reg & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT) + | ((reg & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2); - if (reg_type == type) + if (is_ps && !output && major == 2) { + /* dcl with no explicit usage, look at the register. */ + reg_type = ((reg & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT) + | ((reg & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2); + index = reg & D3DSP_REGNUM_MASK; + if (reg_type >= ARRAY_SIZE(regtype_usage)) + { + WARN("Invalid register type %u.\n", reg_type); + reg_type = 0; + } + usage = regtype_usage[reg_type]; if (semantics) { semantics[i].Usage = usage; - semantics[i].UsageIndex = usage_index; + semantics[i].UsageIndex = index; } - i++; + ++i; } + else if ((!output && reg_type == D3DSPR_INPUT) || (output && reg_type == D3DSPR_OUTPUT)) + { + if (semantics) + { + semantics[i].Usage = + (usage_token & D3DSP_DCL_USAGE_MASK) >> D3DSP_DCL_USAGE_SHIFT; + semantics[i].UsageIndex = + (usage_token & D3DSP_DCL_USAGEINDEX_MASK) >> D3DSP_DCL_USAGEINDEX_SHIFT; + } + ++i; + } + byte_code += 3; + } + else if (!has_dcl) + { + unsigned int len = get_instr_length(byte_code, major, minor) + 1; - ptr++; + switch (*byte_code & 0xffff) + { + case D3DSIO_COMMENT: + case D3DSIO_DEF: + case D3DSIO_DEFB: + case D3DSIO_DEFI: + byte_code += len; + break; + default: + ++byte_code; + while (*byte_code & 0x80000000) + { + reg_type = ((*byte_code & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT) + | ((*byte_code & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2); + index = *byte_code & D3DSP_REGNUM_MASK; + + if ((reg_type == D3DSPR_TEMP && is_ps && major == 1) + || (reg_type == D3DSPR_INPUT && is_ps) + || (reg_type == D3DSPR_TEXTURE && is_ps && !output) + || reg_type == D3DSPR_RASTOUT + || reg_type == D3DSPR_ATTROUT + || reg_type == D3DSPR_OUTPUT + || reg_type == D3DSPR_DEPTHOUT) + { + if (reg_type == D3DSPR_RASTOUT) + rastout |= 1u << index; + else if (reg_type == D3DSPR_DEPTHOUT) + depth = TRUE; + else if (reg_type == D3DSPR_TEXTURE || reg_type == D3DSPR_OUTPUT) + texcoords |= 1u << index; + else + colors |= 1u << index; + } + ++byte_code; + } + } } else { - ptr = skip_instruction(ptr, shader_model); + byte_code += get_instr_length(byte_code, major, minor) + 1; } } - return i; -} - -HRESULT WINAPI D3DXGetShaderInputSemantics(const DWORD *byte_code, D3DXSEMANTIC *semantics, UINT *count) -{ - UINT nb_semantics; - - TRACE("byte_code %p, semantics %p, count %p\n", byte_code, semantics, count); - - if (!byte_code) - return D3DERR_INVALIDCALL; - - nb_semantics = get_shader_semantics(byte_code, semantics, D3DSPR_INPUT); + if (!has_dcl) + { + i = j = 0; + while (texcoords) + { + if (texcoords & 1) + { + if (semantics) + { + semantics[i].Usage = D3DDECLUSAGE_TEXCOORD; + semantics[i].UsageIndex = j; + } + ++i; + } + texcoords >>= 1; + ++j; + } + j = 0; + while (colors) + { + if (colors & 1) + { + if (semantics) + { + semantics[i].Usage = D3DDECLUSAGE_COLOR; + semantics[i].UsageIndex = j; + } + ++i; + } + colors >>= 1; + ++j; + } + j = 0; + while (rastout) + { + if (rastout & 1) + { + if (j >= ARRAY_SIZE(rast_usage)) + { + WARN("Invalid RASTOUT register index.\n"); + usage = 0; + } + else + { + usage = rast_usage[j]; + } + if (semantics) + { + semantics[i].Usage = usage; + semantics[i].UsageIndex = 0; + } + ++i; + } + rastout >>= 1; + ++j; + } + if (depth) + { + if (semantics) + { + semantics[i].Usage = D3DDECLUSAGE_DEPTH; + semantics[i].UsageIndex = 0; + } + ++i; + } + } if (count) - *count = nb_semantics; + *count = i; return D3D_OK; } - -HRESULT WINAPI D3DXGetShaderOutputSemantics(const DWORD *byte_code, D3DXSEMANTIC *semantics, UINT *count) +HRESULT WINAPI D3DXGetShaderInputSemantics(const DWORD *byte_code, D3DXSEMANTIC *semantics, UINT *count) { - UINT nb_semantics; - - TRACE("byte_code %p, semantics %p, count %p\n", byte_code, semantics, count); - - if (!byte_code) - return D3DERR_INVALIDCALL; + TRACE("byte_code %p, semantics %p, count %p.\n", byte_code, semantics, count); - nb_semantics = get_shader_semantics(byte_code, semantics, D3DSPR_OUTPUT); + return get_shader_semantics(byte_code, semantics, count, FALSE); +} - if (count) - *count = nb_semantics; +HRESULT WINAPI D3DXGetShaderOutputSemantics(const DWORD *byte_code, D3DXSEMANTIC *semantics, UINT *count) +{ + TRACE("byte_code %p, semantics %p, count %p.\n", byte_code, semantics, count); - return D3D_OK; + return get_shader_semantics(byte_code, semantics, count, TRUE); } diff --git a/dll/directx/wine/d3dx9_36/skin.c b/dll/directx/wine/d3dx9_36/skin.c index e3f8bf25720..309241ccc08 100644 --- a/dll/directx/wine/d3dx9_36/skin.c +++ b/dll/directx/wine/d3dx9_36/skin.c @@ -2,7 +2,6 @@ * Skin Info operations specific to D3DX9. * * Copyright (C) 2011 Dylan Smith - * Copyright (C) 2013 Christian Costa * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -90,7 +89,7 @@ static ULONG WINAPI d3dx9_skin_info_Release(ID3DXSkinInfo *iface) HeapFree(GetProcessHeap(), 0, skin->bones[i].vertices); HeapFree(GetProcessHeap(), 0, skin->bones[i].weights); } - if (skin->bones) HeapFree(GetProcessHeap(), 0, skin->bones); + HeapFree(GetProcessHeap(), 0, skin->bones); HeapFree(GetProcessHeap(), 0, skin); } @@ -373,89 +372,10 @@ static HRESULT WINAPI d3dx9_skin_info_GetDeclaration(ID3DXSkinInfo *iface, static HRESULT WINAPI d3dx9_skin_info_UpdateSkinnedMesh(ID3DXSkinInfo *iface, const D3DXMATRIX *bone_transforms, const D3DXMATRIX *bone_inv_transpose_transforms, const void *src_vertices, void *dst_vertices) { - struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface); - DWORD size = D3DXGetFVFVertexSize(skin->fvf); - DWORD i, j; - - TRACE("iface %p, bone_transforms %p, bone_inv_transpose_transforms %p, src_vertices %p, dst_vertices %p\n", - skin, bone_transforms, bone_inv_transpose_transforms, src_vertices, dst_vertices); - - if (bone_inv_transpose_transforms) - FIXME("Skinning vertices with two position elements not supported\n"); - - if ((skin->fvf & D3DFVF_POSITION_MASK) != D3DFVF_XYZ) { - FIXME("Vertex type %#x not supported\n", skin->fvf & D3DFVF_POSITION_MASK); - return E_FAIL; - } - - /* Reset all positions */ - for (i = 0; i < skin->num_vertices; i++) { - D3DXVECTOR3 *position = (D3DXVECTOR3*)((BYTE*)dst_vertices + size * i); - position->x = 0.0f; - position->y = 0.0f; - position->z = 0.0f; - } - - /* Update positions that are influenced by bones */ - for (i = 0; i < skin->num_bones; i++) { - D3DXMATRIX bone_inverse, matrix; - - D3DXMatrixInverse(&bone_inverse, NULL, &skin->bones[i].transform); - D3DXMatrixMultiply(&matrix, &bone_transforms[i], &bone_inverse); - D3DXMatrixMultiply(&matrix, &matrix, &skin->bones[i].transform); - - for (j = 0; j < skin->bones[i].num_influences; j++) { - D3DXVECTOR3 position; - D3DXVECTOR3 *position_src = (D3DXVECTOR3*)((BYTE*)src_vertices + size * skin->bones[i].vertices[j]); - D3DXVECTOR3 *position_dest = (D3DXVECTOR3*)((BYTE*)dst_vertices + size * skin->bones[i].vertices[j]); - FLOAT weight = skin->bones[i].weights[j]; - - D3DXVec3TransformCoord(&position, position_src, &matrix); - position_dest->x += weight * position.x; - position_dest->y += weight * position.y; - position_dest->z += weight * position.z; - } - } - - if (skin->fvf & D3DFVF_NORMAL) { - /* Reset all normals */ - for (i = 0; i < skin->num_vertices; i++) { - D3DXVECTOR3 *normal = (D3DXVECTOR3*)((BYTE*)dst_vertices + size * i + sizeof(D3DXVECTOR3)); - normal->x = 0.0f; - normal->y = 0.0f; - normal->z = 0.0f; - } - - /* Update normals that are influenced by bones */ - for (i = 0; i < skin->num_bones; i++) { - D3DXMATRIX bone_inverse, matrix; - - D3DXMatrixInverse(&bone_inverse, NULL, &skin->bones[i].transform); - D3DXMatrixMultiply(&matrix, &skin->bones[i].transform, &bone_transforms[i]); - - for (j = 0; j < skin->bones[i].num_influences; j++) { - D3DXVECTOR3 normal; - D3DXVECTOR3 *normal_src = (D3DXVECTOR3*)((BYTE*)src_vertices + size * skin->bones[i].vertices[j] + sizeof(D3DXVECTOR3)); - D3DXVECTOR3 *normal_dest = (D3DXVECTOR3*)((BYTE*)dst_vertices + size * skin->bones[i].vertices[j] + sizeof(D3DXVECTOR3)); - FLOAT weight = skin->bones[i].weights[j]; - - D3DXVec3TransformNormal(&normal, normal_src, &bone_inverse); - D3DXVec3TransformNormal(&normal, &normal, &matrix); - normal_dest->x += weight * normal.x; - normal_dest->y += weight * normal.y; - normal_dest->z += weight * normal.z; - } - } - - /* Normalize all normals that are influenced by bones*/ - for (i = 0; i < skin->num_vertices; i++) { - D3DXVECTOR3 *normal_dest = (D3DXVECTOR3*)((BYTE*)dst_vertices + (i * size) + sizeof(D3DXVECTOR3)); - if ((normal_dest->x != 0.0f) && (normal_dest->y != 0.0f) && (normal_dest->z != 0.0f)) - D3DXVec3Normalize(normal_dest, normal_dest); - } - } + FIXME("iface %p, bone_transforms %p, bone_inv_transpose_transforms %p, src_vertices %p, dst_vertices %p stub!\n", + iface, bone_transforms, bone_inv_transpose_transforms, src_vertices, dst_vertices); - return D3D_OK; + return E_NOTIMPL; } static HRESULT WINAPI d3dx9_skin_info_ConvertToBlendedMesh(ID3DXSkinInfo *iface, ID3DXMesh *mesh_in, @@ -570,23 +490,3 @@ HRESULT WINAPI D3DXCreateSkinInfoFVF(DWORD num_vertices, DWORD fvf, DWORD num_bo return D3DXCreateSkinInfo(num_vertices, declaration, num_bones, skin_info); } - -HRESULT create_dummy_skin(ID3DXSkinInfo **iface) -{ - static const D3DVERTEXELEMENT9 empty_declaration = D3DDECL_END(); - struct d3dx9_skin_info *object = NULL; - - object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object)); - if (!object) return E_OUTOFMEMORY; - - object->ID3DXSkinInfo_iface.lpVtbl = &d3dx9_skin_info_vtbl; - object->ref = 1; - object->num_vertices = 0; - object->num_bones = 0; - object->vertex_declaration[0] = empty_declaration; - object->fvf = 0; - object->bones = NULL; - - *iface = &object->ID3DXSkinInfo_iface; - return D3D_OK; -} diff --git a/dll/directx/wine/d3dx9_36/sprite.c b/dll/directx/wine/d3dx9_36/sprite.c index 06b08c191a0..ba7181b42e7 100644 --- a/dll/directx/wine/d3dx9_36/sprite.c +++ b/dll/directx/wine/d3dx9_36/sprite.c @@ -204,7 +204,7 @@ static void set_states(struct d3dx9_sprite *object) IDirect3DDevice9_SetRenderState(object->device, D3DRS_ALPHATESTENABLE, object->alphacmp_caps); IDirect3DDevice9_SetRenderState(object->device, D3DRS_BLENDOP, D3DBLENDOP_ADD); IDirect3DDevice9_SetRenderState(object->device, D3DRS_CLIPPING, TRUE); - IDirect3DDevice9_SetRenderState(object->device, D3DRS_CLIPPLANEENABLE, FALSE); + IDirect3DDevice9_SetRenderState(object->device, D3DRS_CLIPPLANEENABLE, 0); IDirect3DDevice9_SetRenderState(object->device, D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED); IDirect3DDevice9_SetRenderState(object->device, D3DRS_CULLMODE, D3DCULL_NONE); diff --git a/dll/directx/wine/d3dx9_36/surface.c b/dll/directx/wine/d3dx9_36/surface.c index f9c4b579f55..321265fbaa6 100644 --- a/dll/directx/wine/d3dx9_36/surface.c +++ b/dll/directx/wine/d3dx9_36/surface.c @@ -106,7 +106,6 @@ static const GUID *d3dformat_to_wic_guid(D3DFORMAT format) #define DDS_PF_RGB 0x40 #define DDS_PF_YUV 0x200 #define DDS_PF_LUMINANCE 0x20000 -#define DDS_PF_BUMPLUMINANCE 0x40000 #define DDS_PF_BUMPDUDV 0x80000 struct dds_pixel_format @@ -262,17 +261,6 @@ static D3DFORMAT dds_bump_to_d3dformat(const struct dds_pixel_format *pixel_form return D3DFMT_UNKNOWN; } -static D3DFORMAT dds_bump_luminance_to_d3dformat(const struct dds_pixel_format *pixel_format) -{ - if (pixel_format->bpp == 32 && pixel_format->rmask == 0x000000ff && pixel_format->gmask == 0x0000ff00 - && pixel_format->bmask == 0x00ff0000) - return D3DFMT_X8L8V8U8; - - WARN("Unknown bump pixel format (%u, %#x, %#x, %#x, %#x)\n", pixel_format->bpp, - pixel_format->rmask, pixel_format->gmask, pixel_format->bmask, pixel_format->amask); - return D3DFMT_UNKNOWN; -} - static D3DFORMAT dds_pixel_format_to_d3dformat(const struct dds_pixel_format *pixel_format) { TRACE("pixel_format: size %u, flags %#x, fourcc %#x, bpp %u.\n", pixel_format->size, @@ -290,8 +278,6 @@ static D3DFORMAT dds_pixel_format_to_d3dformat(const struct dds_pixel_format *pi return dds_alpha_to_d3dformat(pixel_format); if (pixel_format->flags & DDS_PF_BUMPDUDV) return dds_bump_to_d3dformat(pixel_format); - if (pixel_format->flags & DDS_PF_BUMPLUMINANCE) - return dds_bump_luminance_to_d3dformat(pixel_format); WARN("Unknown pixel format (flags %#x, fourcc %#x, bpp %u, r %#x, g %#x, b %#x, a %#x)\n", pixel_format->flags, pixel_format->fourcc, pixel_format->bpp, @@ -322,14 +308,6 @@ static HRESULT d3dformat_to_dds_pixel_format(struct dds_pixel_format *pixel_form } } - /* Reuse dds_fourcc_to_d3dformat as D3DFORMAT and FOURCC are DWORD with same values */ - if (dds_fourcc_to_d3dformat(d3dformat) != D3DFMT_UNKNOWN) - { - pixel_format->flags |= DDS_PF_FOURCC; - pixel_format->fourcc = d3dformat; - return D3D_OK; - } - WARN("Unknown pixel format %#x\n", d3dformat); return E_NOTIMPL; } @@ -538,68 +516,6 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer, IDirect3DSur return D3D_OK; } -static HRESULT get_surface(D3DRESOURCETYPE type, struct IDirect3DBaseTexture9 *tex, - int face, UINT level, struct IDirect3DSurface9 **surf) -{ - switch (type) - { - case D3DRTYPE_TEXTURE: - return IDirect3DTexture9_GetSurfaceLevel((IDirect3DTexture9*) tex, level, surf); - case D3DRTYPE_CUBETEXTURE: - return IDirect3DCubeTexture9_GetCubeMapSurface((IDirect3DCubeTexture9*) tex, face, level, surf); - default: - ERR("Unexpected texture type\n"); - return E_NOTIMPL; - } -} - -HRESULT save_dds_texture_to_memory(ID3DXBuffer **dst_buffer, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette) -{ - HRESULT hr; - D3DRESOURCETYPE type; - UINT mip_levels; - IDirect3DSurface9 *surface; - - type = IDirect3DBaseTexture9_GetType(src_texture); - - if ((type != D3DRTYPE_TEXTURE) && (type != D3DRTYPE_CUBETEXTURE) && (type != D3DRTYPE_VOLUMETEXTURE)) - return D3DERR_INVALIDCALL; - - if (type == D3DRTYPE_CUBETEXTURE) - { - FIXME("Cube texture not supported yet\n"); - return E_NOTIMPL; - } - else if (type == D3DRTYPE_VOLUMETEXTURE) - { - FIXME("Volume texture not supported yet\n"); - return E_NOTIMPL; - } - - mip_levels = IDirect3DTexture9_GetLevelCount(src_texture); - - if (mip_levels > 1) - { - FIXME("Mipmap not supported yet\n"); - return E_NOTIMPL; - } - - if (src_palette) - { - FIXME("Saving surfaces with palettized pixel formats not implemented yet\n"); - return E_NOTIMPL; - } - - hr = get_surface(type, src_texture, D3DCUBEMAP_FACE_POSITIVE_X, 0, &surface); - - if (SUCCEEDED(hr)) - { - hr = save_dds_surface_to_memory(dst_buffer, surface, NULL); - IDirect3DSurface9_Release(surface); - } - - return hr; -} HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const void *src_data, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info) @@ -967,24 +883,6 @@ HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize, } } - /* For 32 bpp BMP, windowscodecs.dll never returns a format with alpha while - * d3dx9_xx.dll returns one if at least 1 pixel has a non zero alpha component */ - if (SUCCEEDED(hr) && (info->Format == D3DFMT_X8R8G8B8) && (info->ImageFileFormat == D3DXIFF_BMP)) { - DWORD size = sizeof(DWORD) * info->Width * info->Height; - BYTE *buffer = HeapAlloc(GetProcessHeap(), 0, size); - hr = IWICBitmapFrameDecode_CopyPixels(frame, NULL, sizeof(DWORD) * info->Width, size, buffer); - if (SUCCEEDED(hr)) { - DWORD i; - for (i = 0; i < info->Width * info->Height; i++) { - if (buffer[i*4+3]) { - info->Format = D3DFMT_A8R8G8B8; - break; - } - } - } - HeapFree(GetProcessHeap(), 0, buffer); - } - if (frame) IWICBitmapFrameDecode_Release(frame); @@ -1813,27 +1711,6 @@ void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slic } } -typedef BOOL (*dxtn_conversion_func)(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, - enum wined3d_format_id format, unsigned int w, unsigned int h); - -static dxtn_conversion_func get_dxtn_conversion_func(D3DFORMAT format, BOOL encode) -{ - switch (format) - { - case D3DFMT_DXT1: - if (!wined3d_dxtn_supported()) return NULL; - return encode ? wined3d_dxt1_encode : wined3d_dxt1_decode; - case D3DFMT_DXT3: - if (!wined3d_dxtn_supported()) return NULL; - return encode ? wined3d_dxt3_encode : wined3d_dxt3_decode; - case D3DFMT_DXT5: - if (!wined3d_dxtn_supported()) return NULL; - return encode ? wined3d_dxt5_encode : wined3d_dxt5_decode; - default: - return NULL; - } -} - /************************************************************ * D3DXLoadSurfaceFromMemory * @@ -1875,7 +1752,6 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, D3DSURFACE_DESC surfdesc; D3DLOCKED_RECT lockrect; struct volume src_size, dst_size; - HRESULT ret = D3D_OK; TRACE("(%p, %p, %s, %p, %#x, %u, %p, %s, %#x, 0x%08x)\n", dst_surface, dst_palette, wine_dbgstr_rect(dst_rect), src_memory, src_format, @@ -1957,15 +1833,8 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, } else /* Stretching or format conversion. */ { - dxtn_conversion_func pre_convert, post_convert; - void *tmp_src_memory = NULL, *tmp_dst_memory = NULL; - UINT tmp_src_pitch, tmp_dst_pitch; - - pre_convert = get_dxtn_conversion_func(srcformatdesc->format, FALSE); - post_convert = get_dxtn_conversion_func(destformatdesc->format, TRUE); - - if ((!pre_convert && !is_conversion_from_supported(srcformatdesc)) || - (!post_convert && !is_conversion_to_supported(destformatdesc))) + if (!is_conversion_from_supported(srcformatdesc) + || !is_conversion_to_supported(destformatdesc)) { FIXME("Unsupported format conversion %#x -> %#x.\n", src_format, surfdesc.Format); return E_NOTIMPL; @@ -1974,52 +1843,10 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, if (FAILED(IDirect3DSurface9_LockRect(dst_surface, &lockrect, dst_rect, 0))) return D3DXERR_INVALIDDATA; - /* handle pre-conversion */ - if (pre_convert) - { - tmp_src_memory = HeapAlloc(GetProcessHeap(), 0, src_size.width * src_size.height * sizeof(DWORD)); - if (!tmp_src_memory) - { - ret = E_OUTOFMEMORY; - goto error; - } - tmp_src_pitch = src_size.width * sizeof(DWORD); - if (!pre_convert(src_memory, tmp_src_memory, src_pitch, tmp_src_pitch, - WINED3DFMT_B8G8R8A8_UNORM, src_size.width, src_size.height)) - { - ret = E_FAIL; - goto error; - } - srcformatdesc = get_format_info(D3DFMT_A8R8G8B8); - } - else - { - tmp_src_memory = (void *)src_memory; - tmp_src_pitch = src_pitch; - } - - /* handle post-conversion */ - if (post_convert) - { - tmp_dst_memory = HeapAlloc(GetProcessHeap(), 0, dst_size.width * dst_size.height * sizeof(DWORD)); - if (!tmp_dst_memory) - { - ret = E_OUTOFMEMORY; - goto error; - } - tmp_dst_pitch = dst_size.width * sizeof(DWORD); - destformatdesc = get_format_info(D3DFMT_A8R8G8B8); - } - else - { - tmp_dst_memory = lockrect.pBits; - tmp_dst_pitch = lockrect.Pitch; - } - if ((filter & 0xf) == D3DX_FILTER_NONE) { - convert_argb_pixels(tmp_src_memory, tmp_src_pitch, 0, &src_size, srcformatdesc, - tmp_dst_memory, tmp_dst_pitch, 0, &dst_size, destformatdesc, color_key, src_palette); + convert_argb_pixels(src_memory, src_pitch, 0, &src_size, srcformatdesc, + lockrect.pBits, lockrect.Pitch, 0, &dst_size, destformatdesc, color_key, src_palette); } else /* if ((filter & 0xf) == D3DX_FILTER_POINT) */ { @@ -2028,30 +1855,14 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, /* Always apply a point filter until D3DX_FILTER_LINEAR, * D3DX_FILTER_TRIANGLE and D3DX_FILTER_BOX are implemented. */ - point_filter_argb_pixels(tmp_src_memory, tmp_src_pitch, 0, &src_size, srcformatdesc, - tmp_dst_memory, tmp_dst_pitch, 0, &dst_size, destformatdesc, color_key, src_palette); + point_filter_argb_pixels(src_memory, src_pitch, 0, &src_size, srcformatdesc, + lockrect.pBits, lockrect.Pitch, 0, &dst_size, destformatdesc, color_key, src_palette); } - /* handle post-conversion */ - if (post_convert) - { - if (!post_convert(tmp_dst_memory, lockrect.pBits, tmp_dst_pitch, lockrect.Pitch, - WINED3DFMT_B8G8R8A8_UNORM, dst_size.width, dst_size.height)) - { - ret = E_FAIL; - goto error; - } - } - -error: - if (pre_convert) - HeapFree(GetProcessHeap(), 0, tmp_src_memory); - if (post_convert) - HeapFree(GetProcessHeap(), 0, tmp_dst_memory); IDirect3DSurface9_UnlockRect(dst_surface); } - return ret; + return D3D_OK; } /************************************************************ diff --git a/dll/directx/wine/d3dx9_36/texture.c b/dll/directx/wine/d3dx9_36/texture.c index d33b4634a52..f4e3231483b 100644 --- a/dll/directx/wine/d3dx9_36/texture.c +++ b/dll/directx/wine/d3dx9_36/texture.c @@ -330,10 +330,10 @@ HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UIN if (fmt->block_width != 1 || fmt->block_height != 1) { - if (w % fmt->block_width) - w += fmt->block_width - w % fmt->block_width; - if (h % fmt->block_height) - h += fmt->block_height - h % fmt->block_height; + if (w < fmt->block_width) + w = fmt->block_width; + if (h < fmt->block_height) + h = fmt->block_height; } if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && (!is_pow2(w))) @@ -1887,7 +1887,10 @@ HRESULT WINAPI D3DXSaveTextureToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE if (!dst_buffer || !src_texture) return D3DERR_INVALIDCALL; if (file_format == D3DXIFF_DDS) - return save_dds_texture_to_memory(dst_buffer, src_texture, src_palette); + { + FIXME("DDS file format isn't supported yet\n"); + return E_NOTIMPL; + } type = IDirect3DBaseTexture9_GetType(src_texture); switch (type) diff --git a/dll/directx/wine/d3dx9_36/util.c b/dll/directx/wine/d3dx9_36/util.c index 90b4705c035..47f9637d83c 100644 --- a/dll/directx/wine/d3dx9_36/util.c +++ b/dll/directx/wine/d3dx9_36/util.c @@ -85,7 +85,6 @@ static const struct pixel_format_desc formats[] = {D3DFMT_G32R32F, { 0, 32, 32, 0}, { 0, 0, 32, 0}, 8, 1, 1, 8, FORMAT_ARGBF, NULL, NULL }, {D3DFMT_A32B32G32R32F, {32, 32, 32, 32}, {96, 0, 32, 64}, 16, 1, 1, 16, FORMAT_ARGBF, NULL, NULL }, {D3DFMT_P8, { 8, 8, 8, 8}, { 0, 0, 0, 0}, 1, 1, 1, 1, FORMAT_INDEX, NULL, index_to_rgba}, - {D3DFMT_X8L8V8U8, { 0, 8, 8, 8}, { 0, 0, 8, 16}, 4, 1, 1, 4, FORMAT_ARGB, NULL, NULL }, /* marks last element */ {D3DFMT_UNKNOWN, { 0, 0, 0, 0}, { 0, 0, 0, 0}, 0, 1, 1, 0, FORMAT_UNKNOWN, NULL, NULL }, }; diff --git a/dll/directx/wine/d3dx9_36/xfile.c b/dll/directx/wine/d3dx9_36/xfile.c index f8c5a2d98d2..795b7bc3ff4 100644 --- a/dll/directx/wine/d3dx9_36/xfile.c +++ b/dll/directx/wine/d3dx9_36/xfile.c @@ -19,9 +19,7 @@ #include "d3dx9_36_private.h" -#include "d3dx9xof.h" -#undef MAKE_DDHRESULT -#include "dxfile.h" +#include static HRESULT error_dxfile_to_d3dxfile(HRESULT error) { diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 98995a1c546..cdd6f78ab47 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -26,7 +26,7 @@ reactos/dll/directx/wine/d3d8 # Synced to Wine-3.0 reactos/dll/directx/wine/d3d9 # Synced to Wine-3.0 reactos/dll/directx/wine/d3dcompiler_43 # Synced to Wine-3.0 reactos/dll/directx/wine/d3drm # Synced to WineStaging-2.16 -reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to WineStaging-2.16 +reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to Wine-3.0 reactos/dll/directx/wine/d3dxof # Synced to WineStaging-2.9 reactos/dll/directx/wine/ddraw # Synced to Wine-3.0 reactos/dll/directx/wine/devenum # Synced to WineStaging-2.9