Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
August 2018
- 62 participants
- 1399 messages
Re: [PATCH 2/3] d3d12/tests: Add test for DXGI_FORMAT_R10G10B10A2_UNORM swapchain.
by Henri Verbeet
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
Aug. 30, 2018
Re: Possible to call winlib function from native program ?
by Stefan Dösinger
Hello Wilma,
You need to compile and link your entire application with winegcc (or
wineg++) and run it through Wine. winegcc will give you a file
app.exe.so, which you can run with "wine app.exe.so". It'll also create
an app.exe shell script that invokes Wine for you.
The reason why you cannot simply dlopen a Wine DLL and call code from it
is that Wine's DLLs depend on having a running wineserver instance to
take care of Windows kernel tasks that do not exist on the Linux side,
e.g. the registry. Furthermore dependencies between Wine DLLs are
resolved via PE exports / imports, so when you dlopen crypt32.dll the
required user32.dll, advapi32.dll and bcrypt.dll libs won't be loaded
and linked.
A winelib-linked program can call link to and call any Linux shared
library. If the Wine-dependent functionality is relatively small and you
do not with to have all of Wine loaded whenever your program is running,
you could consider making the Wine-dependent bits run in an external
process and communicate via pipes, sockets or shared memory with your
main program.
I hope this helps.
Stefan
Am 2018-08-30 um 13:00 schrieb Wilma Feuerstein:
> I'm trying to call a winelib-function from a Linux C/C++ shared-library.
> The reason for it is, that I want to call some wine-dll-functions from C#.
>
>
> I wrote a wineg++/winegcc compiled shared-library (libtest.c), which I
> want to call from a gcc/g++ main program (for testing).
>
> Inside the shared library, I try to call CryptProtectData (in
> Crypt32.lib) and GetVersionEx (Kernel32.lib) - for a test - and just
> printf the results.
> Inside the main application, I dlopen the shared library,
> and dlsym the wrapper-function which calls CryptProtectData/GetVersionEx,
> then I try to execute that wrapper function.
>
> But as soon as the execution hits the CryptProtectData/GetVersionEx, I
> get *Segmentation fault (core dumped)* .
>
> Why ?
> The source-code for calling the CryptProtectData/GetVersionEx function
> works, tested it on Windows.
> Invoking a dlsym-ed function that doesn't call a wine-function works as
> well.
> But invoking a dlsym-ed function that calls a winelib-function does NOT
> work (segmentation fault).
> Do I need to call any undocumented wine init-code ?
> Or what is the problem ?
> Can I even run libtest.dll.so inside an application that isn't run with
> wine / that isn't compiled with wineg++ ?
> If the latter is the case, is there some hack somewhere to make it work ?
> Basically all such a hack would need to do is loading some libraries,
> and execute some init code, or not ?
>
> |wineg++-m64 -shared -fPIC -Wall-lrt -ldl -lpthread -lwine -lmsvcrt
> -lcrypt32 -lusp10 -o libtest.so libtest.c g++-m64 app.c -ldl -o app ./app|
>
>
> Details/Code here:
> https://stackoverflow.com/questions/52093440/how-to-call-wine-dll-functions…
>
>
>
>
Aug. 30, 2018
[PATCH v2] shell32/autocomplete: Revamp pwzsRegKeyPath handling so it can deal with arbitrary sizes and make it more robust
by Gabriel Ivăncescu
Handle heap_alloc failure, reg strings without a \ character at all, try
harder to find the reg path (if only value fails the lookup), and read the
registry value with any size.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com>
---
v2: Retrieve the registry value without failing in rare race conditions.
dlls/shell32/autocomplete.c | 93 +++++++++++++++++++++++++++++----------------
1 file changed, 61 insertions(+), 32 deletions(-)
diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c
index 5fe48e9..99d5ae7 100644
--- a/dlls/shell32/autocomplete.c
+++ b/dlls/shell32/autocomplete.c
@@ -486,40 +486,69 @@ static HRESULT WINAPI IAutoComplete2_fnInit(
if (This->options & ACO_AUTOSUGGEST)
create_listbox(This);
- if (pwzsRegKeyPath) {
- WCHAR *key;
- WCHAR result[MAX_PATH];
- WCHAR *value;
- HKEY hKey = 0;
- LONG res;
- LONG len;
-
- /* pwszRegKeyPath contains the key as well as the value, so we split */
- key = heap_alloc((lstrlenW(pwzsRegKeyPath)+1)*sizeof(WCHAR));
- strcpyW(key, pwzsRegKeyPath);
- value = strrchrW(key, '\\');
- *value = 0;
- value++;
- /* Now value contains the value and buffer the key */
- res = RegOpenKeyExW(HKEY_CURRENT_USER, key, 0, KEY_READ, &hKey);
- if (res != ERROR_SUCCESS) {
- /* if the key is not found, MSDN states we must seek in HKEY_LOCAL_MACHINE */
- res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hKey);
- }
- if (res == ERROR_SUCCESS) {
- res = RegQueryValueW(hKey, value, result, &len);
- if (res == ERROR_SUCCESS) {
- This->quickComplete = heap_alloc(len*sizeof(WCHAR));
- strcpyW(This->quickComplete, result);
- }
- RegCloseKey(hKey);
- }
- heap_free(key);
+ if (pwzsRegKeyPath)
+ {
+ WCHAR *key, *value;
+ DWORD type, sz = MAX_PATH * sizeof(WCHAR);
+ BYTE *qc;
+ HKEY hKey;
+ LSTATUS res;
+ size_t len;
+
+ /* pwszRegKeyPath contains the key as well as the value, so split it */
+ value = strrchrW(pwzsRegKeyPath, '\\');
+ len = value - pwzsRegKeyPath;
+
+ if (value && (key = heap_alloc((len+1) * sizeof(*key))) != NULL) {
+ memcpy(key, pwzsRegKeyPath, len * sizeof(*key));
+ key[len] = '\0';
+ value++;
+
+ res = RegOpenKeyExW(HKEY_CURRENT_USER, key, 0, KEY_READ, &hKey);
+
+ /* if not found, MSDN states we must seek in HKEY_LOCAL_MACHINE */
+ if (res != ERROR_SUCCESS)
+ res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hKey);
+
+ if (res == ERROR_SUCCESS && (qc = heap_alloc(sz)) != NULL) {
+ res = RegQueryValueExW(hKey, value, NULL, &type, qc, &sz);
+
+ if ((res != ERROR_SUCCESS && res != ERROR_MORE_DATA) || type != REG_SZ)
+ {
+ RegCloseKey(hKey);
+ res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hKey);
+ if (res != ERROR_SUCCESS) {
+ heap_free(qc);
+ goto free_key_str;
+ }
+ sz = MAX_PATH * sizeof(WCHAR);
+ res = RegQueryValueExW(hKey, value, NULL, &type, qc, &sz);
+ }
+
+ for (;;) {
+ if (res == ERROR_SUCCESS && type == REG_SZ) {
+ This->quickComplete = heap_realloc(qc, sz);
+ break;
+ }
+ heap_free(qc);
+ if (res != ERROR_MORE_DATA || type != REG_SZ)
+ break;
+ if ((qc = heap_alloc(sz)) == NULL)
+ break;
+ res = RegQueryValueExW(hKey, value, NULL, &type, qc, &sz);
+ }
+ RegCloseKey(hKey);
+ }
+ free_key_str:
+ heap_free(key);
+ }
}
- if ((pwszQuickComplete) && (!This->quickComplete)) {
- This->quickComplete = heap_alloc((lstrlenW(pwszQuickComplete)+1)*sizeof(WCHAR));
- lstrcpyW(This->quickComplete, pwszQuickComplete);
+ if (!This->quickComplete && pwszQuickComplete)
+ {
+ size_t len = strlenW(pwszQuickComplete)+1;
+ if ((This->quickComplete = heap_alloc(len * sizeof(WCHAR))) != NULL)
+ memcpy(This->quickComplete, pwszQuickComplete, len * sizeof(WCHAR));
}
return S_OK;
--
1.9.1
Aug. 30, 2018
[PATCH 3/3] wined3d: Use get_format_internal() in init_format_filter_info().
by Józef Kucia
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
dlls/wined3d/utils.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 5720cabba99e..d75cbc1a1645 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -3330,7 +3330,7 @@ static void init_format_filter_info(struct wined3d_adapter *adapter,
{
enum wined3d_pci_vendor vendor = adapter->driver_info.vendor;
struct wined3d_format *format;
- unsigned int fmt_idx, i;
+ unsigned int i;
static const enum wined3d_format_id fmts16[] =
{
WINED3DFMT_R16_FLOAT,
@@ -3339,8 +3339,8 @@ static void init_format_filter_info(struct wined3d_adapter *adapter,
};
BOOL filtered;
+ /* This was already handled by init_format_texture_info(). */
if (gl_info->supported[ARB_INTERNALFORMAT_QUERY2])
- /* This was already handled by init_format_texture_info(). */
return;
if (wined3d_settings.offscreen_rendering_mode != ORM_FBO
@@ -3367,8 +3367,8 @@ static void init_format_filter_info(struct wined3d_adapter *adapter,
{
for (i = 0; i < ARRAY_SIZE(fmts16); ++i)
{
- fmt_idx = get_format_idx(fmts16[i]);
- format_set_flag(&adapter->formats[fmt_idx], WINED3DFMT_FLAG_FILTERING);
+ format = get_format_internal(adapter, fmts16[i]);
+ format_set_flag(format, WINED3DFMT_FLAG_FILTERING);
}
}
return;
@@ -3376,19 +3376,19 @@ static void init_format_filter_info(struct wined3d_adapter *adapter,
for (i = 0; i < ARRAY_SIZE(fmts16); ++i)
{
- fmt_idx = get_format_idx(fmts16[i]);
- format = &adapter->formats[fmt_idx];
- if (!format->glInternal) continue; /* Not supported by GL */
+ format = get_format_internal(adapter, fmts16[i]);
+ if (!format->glInternal)
+ continue; /* Not supported by GL */
- filtered = check_filter(gl_info, adapter->formats[fmt_idx].glInternal);
+ filtered = check_filter(gl_info, format->glInternal);
if (filtered)
{
- TRACE("Format %s supports filtering\n", debug_d3dformat(fmts16[i]));
+ TRACE("Format %s supports filtering.\n", debug_d3dformat(format->id));
format_set_flag(format, WINED3DFMT_FLAG_FILTERING);
}
else
{
- TRACE("Format %s does not support filtering\n", debug_d3dformat(fmts16[i]));
+ TRACE("Format %s does not support filtering.\n", debug_d3dformat(format->id));
}
}
}
--
2.16.4
Aug. 30, 2018
[PATCH 2/3] wined3d: Use get_format_internal() in apply_format_fixups().
by Józef Kucia
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
dlls/wined3d/utils.c | 198 +++++++++++++++++++++++++--------------------------
1 file changed, 99 insertions(+), 99 deletions(-)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index bc225878e5e8..5720cabba99e 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -3395,27 +3395,27 @@ static void init_format_filter_info(struct wined3d_adapter *adapter,
static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_gl_info *gl_info)
{
+ struct wined3d_format *format;
unsigned int i;
- int idx;
- idx = get_format_idx(WINED3DFMT_R16_FLOAT);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_R16_FLOAT);
+ format->color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
- idx = get_format_idx(WINED3DFMT_R32_FLOAT);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_R32_FLOAT);
+ format->color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
- idx = get_format_idx(WINED3DFMT_R16G16_UNORM);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_R16G16_UNORM);
+ format->color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
- idx = get_format_idx(WINED3DFMT_R16G16_FLOAT);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_R16G16_FLOAT);
+ format->color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
- idx = get_format_idx(WINED3DFMT_R32G32_FLOAT);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_R32G32_FLOAT);
+ format->color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
/* GL_ATI_envmap_bumpmap in theory supports R8G8_SNORM but is no longer supported by
@@ -3425,163 +3425,163 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
/* R8G8_SNORM and R16G16_SNORM need a fixup of the undefined blue channel. OpenGL
* returns 0.0 when sampling from it, DirectX 1.0. So we always have in-shader
* conversion for this format. */
- idx = get_format_idx(WINED3DFMT_R8G8_SNORM);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_R8G8_SNORM);
+ format->color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
- idx = get_format_idx(WINED3DFMT_R16G16_SNORM);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_R16G16_SNORM);
+ format->color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
}
else
{
/* Emulate using unsigned formats. This requires load-time conversion in addition to the
* fixups here. */
- idx = get_format_idx(WINED3DFMT_R8G8_SNORM);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_R8G8_SNORM);
+ format->color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
- idx = get_format_idx(WINED3DFMT_R16G16_SNORM);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_R16G16_SNORM);
+ format->color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
- idx = get_format_idx(WINED3DFMT_R8G8B8A8_SNORM);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_R8G8B8A8_SNORM);
+ format->color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 1, CHANNEL_SOURCE_Z, 1, CHANNEL_SOURCE_W);
- idx = get_format_idx(WINED3DFMT_R5G5_SNORM_L6_UNORM);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_R5G5_SNORM_L6_UNORM);
+ format->color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE);
}
if (!gl_info->supported[NV_TEXTURE_SHADER])
{
- idx = get_format_idx(WINED3DFMT_R8G8_SNORM_L8X8_UNORM);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_R8G8_SNORM_L8X8_UNORM);
+ format->color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_W);
}
if (gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] || gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC])
{
- idx = get_format_idx(WINED3DFMT_ATI1N);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_ATI1N);
+ format->color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X);
- idx = get_format_idx(WINED3DFMT_ATI2N);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_ATI2N);
+ format->color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
}
else if (gl_info->supported[ATI_TEXTURE_COMPRESSION_3DC])
{
- idx = get_format_idx(WINED3DFMT_ATI2N);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_ATI2N);
+ format->color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_W, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
}
if (!gl_info->supported[APPLE_YCBCR_422] && (gl_info->supported[ARB_FRAGMENT_PROGRAM]
|| (gl_info->supported[ARB_FRAGMENT_SHADER] && gl_info->supported[ARB_VERTEX_SHADER])))
{
- idx = get_format_idx(WINED3DFMT_YUY2);
- adapter->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YUY2);
+ format = get_format_internal(adapter, WINED3DFMT_YUY2);
+ format->color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YUY2);
- idx = get_format_idx(WINED3DFMT_UYVY);
- adapter->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_UYVY);
+ format = get_format_internal(adapter, WINED3DFMT_UYVY);
+ format->color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_UYVY);
}
else if (!gl_info->supported[APPLE_YCBCR_422] && (!gl_info->supported[ARB_FRAGMENT_PROGRAM]
&& (!gl_info->supported[ARB_FRAGMENT_SHADER] || !gl_info->supported[ARB_VERTEX_SHADER])))
{
- idx = get_format_idx(WINED3DFMT_YUY2);
- adapter->formats[idx].glInternal = 0;
+ format = get_format_internal(adapter, WINED3DFMT_YUY2);
+ format->glInternal = 0;
- idx = get_format_idx(WINED3DFMT_UYVY);
- adapter->formats[idx].glInternal = 0;
+ format = get_format_internal(adapter, WINED3DFMT_UYVY);
+ format->glInternal = 0;
}
if (gl_info->supported[ARB_FRAGMENT_PROGRAM]
|| (gl_info->supported[ARB_FRAGMENT_SHADER] && gl_info->supported[ARB_VERTEX_SHADER]))
{
- idx = get_format_idx(WINED3DFMT_YV12);
- format_set_flag(&adapter->formats[idx], WINED3DFMT_FLAG_HEIGHT_SCALE);
- adapter->formats[idx].height_scale.numerator = 3;
- adapter->formats[idx].height_scale.denominator = 2;
- adapter->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YV12);
+ format = get_format_internal(adapter, WINED3DFMT_YV12);
+ format_set_flag(format, WINED3DFMT_FLAG_HEIGHT_SCALE);
+ format->height_scale.numerator = 3;
+ format->height_scale.denominator = 2;
+ format->color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YV12);
- idx = get_format_idx(WINED3DFMT_NV12);
- format_set_flag(&adapter->formats[idx], WINED3DFMT_FLAG_HEIGHT_SCALE);
- adapter->formats[idx].height_scale.numerator = 3;
- adapter->formats[idx].height_scale.denominator = 2;
- adapter->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_NV12);
+ format = get_format_internal(adapter, WINED3DFMT_NV12);
+ format_set_flag(format, WINED3DFMT_FLAG_HEIGHT_SCALE);
+ format->height_scale.numerator = 3;
+ format->height_scale.denominator = 2;
+ format->color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_NV12);
}
else
{
- idx = get_format_idx(WINED3DFMT_YV12);
- adapter->formats[idx].glInternal = 0;
+ format = get_format_internal(adapter, WINED3DFMT_YV12);
+ format->glInternal = 0;
- idx = get_format_idx(WINED3DFMT_NV12);
- adapter->formats[idx].glInternal = 0;
+ format = get_format_internal(adapter, WINED3DFMT_NV12);
+ format->glInternal = 0;
}
if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
{
- idx = get_format_idx(WINED3DFMT_A8_UNORM);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_A8_UNORM);
+ format->color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_ZERO, 0, CHANNEL_SOURCE_ZERO, 0, CHANNEL_SOURCE_ZERO, 0, CHANNEL_SOURCE_X);
- idx = get_format_idx(WINED3DFMT_L8A8_UNORM);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_L8A8_UNORM);
+ format->color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y);
- idx = get_format_idx(WINED3DFMT_L4A4_UNORM);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_L4A4_UNORM);
+ format->color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y);
- idx = get_format_idx(WINED3DFMT_L16_UNORM);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_L16_UNORM);
+ format->color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE);
- idx = get_format_idx(WINED3DFMT_INTZ);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_INTZ);
+ format->color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X);
}
if (gl_info->supported[ARB_TEXTURE_RG])
{
- idx = get_format_idx(WINED3DFMT_L8_UNORM);
- adapter->formats[idx].color_fixup = create_color_fixup_desc(
+ format = get_format_internal(adapter, WINED3DFMT_L8_UNORM);
+ format->color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE);
}
if (gl_info->supported[ARB_FRAGMENT_PROGRAM] || gl_info->supported[ARB_FRAGMENT_SHADER])
{
- idx = get_format_idx(WINED3DFMT_P8_UINT);
- adapter->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_P8);
+ format = get_format_internal(adapter, WINED3DFMT_P8_UINT);
+ format->color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_P8);
}
if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA])
{
- idx = get_format_idx(WINED3DFMT_B8G8R8A8_UNORM);
- adapter->formats[idx].gl_vtx_format = GL_BGRA;
+ format = get_format_internal(adapter, WINED3DFMT_B8G8R8A8_UNORM);
+ format->gl_vtx_format = GL_BGRA;
}
if (!gl_info->supported[ARB_HALF_FLOAT_VERTEX])
{
/* Do not change the size of the type, it is CPU side. We have to change the GPU-side information though.
* It is the job of the vertex buffer code to make sure that the vbos have the right format */
- idx = get_format_idx(WINED3DFMT_R16G16_FLOAT);
- adapter->formats[idx].gl_vtx_type = GL_FLOAT;
+ format = get_format_internal(adapter, WINED3DFMT_R16G16_FLOAT);
+ format->gl_vtx_type = GL_FLOAT;
- idx = get_format_idx(WINED3DFMT_R16G16B16A16_FLOAT);
- adapter->formats[idx].gl_vtx_type = GL_FLOAT;
+ format = get_format_internal(adapter, WINED3DFMT_R16G16B16A16_FLOAT);
+ format->gl_vtx_type = GL_FLOAT;
}
if (!gl_info->supported[ARB_HALF_FLOAT_PIXEL])
{
- idx = get_format_idx(WINED3DFMT_R16_FLOAT);
- format_clear_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE);
+ format = get_format_internal(adapter, WINED3DFMT_R16_FLOAT);
+ format_clear_flag(format, WINED3DFMT_FLAG_TEXTURE);
- idx = get_format_idx(WINED3DFMT_R16G16_FLOAT);
- format_clear_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE);
+ format = get_format_internal(adapter, WINED3DFMT_R16G16_FLOAT);
+ format_clear_flag(format, WINED3DFMT_FLAG_TEXTURE);
- idx = get_format_idx(WINED3DFMT_R16G16B16A16_FLOAT);
- format_clear_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE);
+ format = get_format_internal(adapter, WINED3DFMT_R16G16B16A16_FLOAT);
+ format_clear_flag(format, WINED3DFMT_FLAG_TEXTURE);
}
if (gl_info->quirks & WINED3D_QUIRK_BROKEN_RGBA16)
{
- idx = get_format_idx(WINED3DFMT_R16G16B16A16_UNORM);
- format_clear_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE);
+ format = get_format_internal(adapter, WINED3DFMT_R16G16B16A16_UNORM);
+ format_clear_flag(format, WINED3DFMT_FLAG_TEXTURE);
}
/* ATI instancing hack: Although ATI cards do not support Shader Model
@@ -3599,8 +3599,8 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
/* FIXME: This should just check the shader backend caps. */
if (gl_info->supported[ARB_VERTEX_PROGRAM] || gl_info->supported[ARB_VERTEX_SHADER])
{
- idx = get_format_idx(WINED3DFMT_INST);
- format_set_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE);
+ format = get_format_internal(adapter, WINED3DFMT_INST);
+ format_set_flag(format, WINED3DFMT_FLAG_TEXTURE);
}
/* Depth bound test. To query if the card supports it CheckDeviceFormat()
@@ -3611,8 +3611,8 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
* value. */
if (gl_info->supported[EXT_DEPTH_BOUNDS_TEST])
{
- idx = get_format_idx(WINED3DFMT_NVDB);
- format_set_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE);
+ format = get_format_internal(adapter, WINED3DFMT_NVDB);
+ format_set_flag(format, WINED3DFMT_FLAG_TEXTURE);
}
/* RESZ aka AMD DX9-level hack for multisampled depth buffer resolve. You query for RESZ
@@ -3620,8 +3620,8 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
* RENDERTARGET usage. */
if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
{
- idx = get_format_idx(WINED3DFMT_RESZ);
- format_set_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_RENDERTARGET);
+ format = get_format_internal(adapter, WINED3DFMT_RESZ);
+ format_set_flag(format, WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_RENDERTARGET);
}
for (i = 0; i < adapter->format_count; ++i)
@@ -3650,18 +3650,18 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
/* These formats are not supported for 3D textures. See also
* WINED3DFMT_FLAG_DECOMPRESS. */
- idx = get_format_idx(WINED3DFMT_ATI1N);
- adapter->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
- idx = get_format_idx(WINED3DFMT_ATI2N);
- adapter->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
- idx = get_format_idx(WINED3DFMT_BC4_UNORM);
- adapter->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
- idx = get_format_idx(WINED3DFMT_BC4_SNORM);
- adapter->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
- idx = get_format_idx(WINED3DFMT_BC5_UNORM);
- adapter->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
- idx = get_format_idx(WINED3DFMT_BC5_SNORM);
- adapter->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
+ format = get_format_internal(adapter, WINED3DFMT_ATI1N);
+ format->flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
+ format = get_format_internal(adapter, WINED3DFMT_ATI2N);
+ format->flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
+ format = get_format_internal(adapter, WINED3DFMT_BC4_UNORM);
+ format->flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
+ format = get_format_internal(adapter, WINED3DFMT_BC4_SNORM);
+ format->flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
+ format = get_format_internal(adapter, WINED3DFMT_BC5_UNORM);
+ format->flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
+ format = get_format_internal(adapter, WINED3DFMT_BC5_SNORM);
+ format->flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
}
static unsigned int calculate_vertex_attribute_size(GLenum type, unsigned int component_count)
--
2.16.4
Aug. 30, 2018
[PATCH 1/3] wined3d: Move formats from gl_info to wined3d_adapter.
by Józef Kucia
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
dlls/wined3d/directx.c | 5 +-
dlls/wined3d/texture.c | 1 -
dlls/wined3d/utils.c | 236 +++++++++++++++++++++--------------------
dlls/wined3d/wined3d_private.h | 6 +-
4 files changed, 127 insertions(+), 121 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 8fa3a2492dfe..ab6a452a2e8c 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -73,7 +73,7 @@ UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount)
static void wined3d_adapter_cleanup(struct wined3d_adapter *adapter)
{
- heap_free(adapter->gl_info.formats);
+ heap_free(adapter->formats);
heap_free(adapter->cfgs);
}
@@ -2512,6 +2512,9 @@ static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, unsigned int o
TRACE("Allocated LUID %08x:%08x for adapter %p.\n",
adapter->luid.HighPart, adapter->luid.LowPart, adapter);
+ adapter->formats = NULL;
+ adapter->format_count = 0;
+
if (wined3d_creation_flags & WINED3D_NO3D)
return wined3d_adapter_no3d_init(adapter);
return wined3d_adapter_opengl_init(adapter, wined3d_creation_flags);
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index f72442d1ddfe..8f499d4ada60 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -2656,7 +2656,6 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
if (desc->resource_type != WINED3D_RTYPE_TEXTURE_3D && !gl_info->supported[ARB_TEXTURE_RECTANGLE]
&& !gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT])
{
-
/* TODO: Add support for non-power-of-two compressed textures. */
if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D]
& (WINED3DFMT_FLAG_COMPRESSED | WINED3DFMT_FLAG_HEIGHT_SCALE))
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 0c80756e2a87..bc225878e5e8 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -1936,7 +1936,7 @@ static inline int get_format_idx(enum wined3d_format_id format_id)
return -1;
}
-static struct wined3d_format *get_format_internal(struct wined3d_gl_info *gl_info,
+static struct wined3d_format *get_format_internal(const struct wined3d_adapter *adapter,
enum wined3d_format_id format_id)
{
int fmt_idx;
@@ -1947,7 +1947,7 @@ static struct wined3d_format *get_format_internal(struct wined3d_gl_info *gl_inf
return NULL;
}
- return &gl_info->formats[fmt_idx];
+ return &adapter->formats[fmt_idx];
}
static void copy_format(struct wined3d_format *dst_format, const struct wined3d_format *src_format)
@@ -1999,14 +1999,14 @@ static enum wined3d_channel_type map_channel_type(char t)
}
}
-static BOOL init_format_base_info(struct wined3d_gl_info *gl_info)
+static BOOL init_format_base_info(struct wined3d_adapter *adapter)
{
struct wined3d_format *format;
unsigned int i, j;
- gl_info->format_count = WINED3D_FORMAT_COUNT;
- if (!(gl_info->formats = heap_calloc(gl_info->format_count
- + ARRAY_SIZE(typeless_depth_stencil_formats), sizeof(*gl_info->formats))))
+ adapter->format_count = WINED3D_FORMAT_COUNT;
+ if (!(adapter->formats = heap_calloc(adapter->format_count
+ + ARRAY_SIZE(typeless_depth_stencil_formats), sizeof(*adapter->formats))))
{
ERR("Failed to allocate memory.\n");
return FALSE;
@@ -2014,7 +2014,7 @@ static BOOL init_format_base_info(struct wined3d_gl_info *gl_info)
for (i = 0; i < ARRAY_SIZE(formats); ++i)
{
- if (!(format = get_format_internal(gl_info, formats[i].id)))
+ if (!(format = get_format_internal(adapter, formats[i].id)))
goto fail;
format->id = formats[i].id;
@@ -2039,10 +2039,10 @@ static BOOL init_format_base_info(struct wined3d_gl_info *gl_info)
const struct wined3d_format *typeless_format;
DWORD flags = 0;
- if (!(format = get_format_internal(gl_info, typed_formats[i].id)))
+ if (!(format = get_format_internal(adapter, typed_formats[i].id)))
goto fail;
- if (!(typeless_format = get_format_internal(gl_info, typed_formats[i].typeless_id)))
+ if (!(typeless_format = get_format_internal(adapter, typed_formats[i].typeless_id)))
goto fail;
format->id = typed_formats[i].id;
@@ -2082,7 +2082,7 @@ static BOOL init_format_base_info(struct wined3d_gl_info *gl_info)
for (i = 0; i < ARRAY_SIZE(ddi_formats); ++i)
{
- if (!(format = get_format_internal(gl_info, ddi_formats[i].id)))
+ if (!(format = get_format_internal(adapter, ddi_formats[i].id)))
goto fail;
format->ddi_format = ddi_formats[i].ddi_format;
@@ -2090,7 +2090,7 @@ static BOOL init_format_base_info(struct wined3d_gl_info *gl_info)
for (i = 0; i < ARRAY_SIZE(format_base_flags); ++i)
{
- if (!(format = get_format_internal(gl_info, format_base_flags[i].id)))
+ if (!(format = get_format_internal(adapter, format_base_flags[i].id)))
goto fail;
format_set_flag(format, format_base_flags[i].flags);
@@ -2099,18 +2099,18 @@ static BOOL init_format_base_info(struct wined3d_gl_info *gl_info)
return TRUE;
fail:
- heap_free(gl_info->formats);
+ heap_free(adapter->formats);
return FALSE;
}
-static BOOL init_format_block_info(struct wined3d_gl_info *gl_info)
+static BOOL init_format_block_info(struct wined3d_adapter *adapter)
{
struct wined3d_format *format;
unsigned int i;
for (i = 0; i < ARRAY_SIZE(format_block_info); ++i)
{
- if (!(format = get_format_internal(gl_info, format_block_info[i].id)))
+ if (!(format = get_format_internal(adapter, format_block_info[i].id)))
return FALSE;
format->block_width = format_block_info[i].block_width;
@@ -2135,14 +2135,14 @@ static BOOL init_format_block_info(struct wined3d_gl_info *gl_info)
*
* Affected applications include "Heroes VI", "From Dust", "Halo Online" and
* "Eldorado". */
-static BOOL init_format_decompress_info(struct wined3d_gl_info *gl_info)
+static BOOL init_format_decompress_info(struct wined3d_adapter *adapter)
{
struct wined3d_format *format;
unsigned int i;
for (i = 0; i < ARRAY_SIZE(format_decompress_info); ++i)
{
- if (!(format = get_format_internal(gl_info, format_decompress_info[i].id)))
+ if (!(format = get_format_internal(adapter, format_decompress_info[i].id)))
return FALSE;
format->flags[WINED3D_GL_RES_TYPE_TEX_3D] |= WINED3DFMT_FLAG_DECOMPRESS;
@@ -2723,7 +2723,8 @@ static void query_format_flag(struct wined3d_gl_info *gl_info, struct wined3d_fo
}
/* Context activation is done by the caller. */
-static void init_format_fbo_compat_info(struct wined3d_caps_gl_ctx *ctx)
+static void init_format_fbo_compat_info(const struct wined3d_adapter *adapter,
+ struct wined3d_caps_gl_ctx *ctx)
{
const struct wined3d_gl_info *gl_info = ctx->gl_info;
unsigned int i, type;
@@ -2731,12 +2732,12 @@ static void init_format_fbo_compat_info(struct wined3d_caps_gl_ctx *ctx)
if (gl_info->supported[ARB_INTERNALFORMAT_QUERY2])
{
- for (i = 0; i < gl_info->format_count; ++i)
+ for (i = 0; i < adapter->format_count; ++i)
{
- GLint value;
- struct wined3d_format *format = &gl_info->formats[i];
BOOL fallback_fmt_used = FALSE, regular_fmt_used = FALSE;
+ struct wined3d_format *format = &adapter->formats[i];
GLenum rt_internal = format->rtInternal;
+ GLint value;
if (!format->glInternal)
continue;
@@ -2845,9 +2846,9 @@ static void init_format_fbo_compat_info(struct wined3d_caps_gl_ctx *ctx)
gl_info->gl_ops.gl.p_glReadBuffer(GL_COLOR_ATTACHMENT0);
}
- for (i = 0; i < gl_info->format_count; ++i)
+ for (i = 0; i < adapter->format_count; ++i)
{
- struct wined3d_format *format = &gl_info->formats[i];
+ struct wined3d_format *format = &adapter->formats[i];
if (!format->glInternal) continue;
@@ -3125,7 +3126,7 @@ static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct win
for (i = 0; i < ARRAY_SIZE(format_texture_info); ++i)
{
- if (!(format = get_format_internal(gl_info, format_texture_info[i].id)))
+ if (!(format = get_format_internal(adapter, format_texture_info[i].id)))
return FALSE;
if (!gl_info->supported[format_texture_info[i].extension])
@@ -3189,7 +3190,7 @@ static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct win
{
if (format_srgb_info[j].base_format_id == format->id)
{
- if (!(srgb_format = get_format_internal(gl_info, format_srgb_info[j].srgb_format_id)))
+ if (!(srgb_format = get_format_internal(adapter, format_srgb_info[j].srgb_format_id)))
return FALSE;
break;
}
@@ -3324,8 +3325,10 @@ static BOOL check_filter(const struct wined3d_gl_info *gl_info, GLenum internal)
return ret;
}
-static void init_format_filter_info(struct wined3d_gl_info *gl_info, enum wined3d_pci_vendor vendor)
+static void init_format_filter_info(struct wined3d_adapter *adapter,
+ struct wined3d_gl_info *gl_info)
{
+ enum wined3d_pci_vendor vendor = adapter->driver_info.vendor;
struct wined3d_format *format;
unsigned int fmt_idx, i;
static const enum wined3d_format_id fmts16[] =
@@ -3365,7 +3368,7 @@ static void init_format_filter_info(struct wined3d_gl_info *gl_info, enum wined3
for (i = 0; i < ARRAY_SIZE(fmts16); ++i)
{
fmt_idx = get_format_idx(fmts16[i]);
- format_set_flag(&gl_info->formats[fmt_idx], WINED3DFMT_FLAG_FILTERING);
+ format_set_flag(&adapter->formats[fmt_idx], WINED3DFMT_FLAG_FILTERING);
}
}
return;
@@ -3374,10 +3377,10 @@ static void init_format_filter_info(struct wined3d_gl_info *gl_info, enum wined3
for (i = 0; i < ARRAY_SIZE(fmts16); ++i)
{
fmt_idx = get_format_idx(fmts16[i]);
- format = &gl_info->formats[fmt_idx];
+ format = &adapter->formats[fmt_idx];
if (!format->glInternal) continue; /* Not supported by GL */
- filtered = check_filter(gl_info, gl_info->formats[fmt_idx].glInternal);
+ filtered = check_filter(gl_info, adapter->formats[fmt_idx].glInternal);
if (filtered)
{
TRACE("Format %s supports filtering\n", debug_d3dformat(fmts16[i]));
@@ -3396,23 +3399,23 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
int idx;
idx = get_format_idx(WINED3DFMT_R16_FLOAT);
- gl_info->formats[idx].color_fixup = create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
idx = get_format_idx(WINED3DFMT_R32_FLOAT);
- gl_info->formats[idx].color_fixup = create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
idx = get_format_idx(WINED3DFMT_R16G16_UNORM);
- gl_info->formats[idx].color_fixup = create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
idx = get_format_idx(WINED3DFMT_R16G16_FLOAT);
- gl_info->formats[idx].color_fixup = create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
idx = get_format_idx(WINED3DFMT_R32G32_FLOAT);
- gl_info->formats[idx].color_fixup = create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
/* GL_ATI_envmap_bumpmap in theory supports R8G8_SNORM but is no longer supported by
@@ -3423,10 +3426,10 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
* returns 0.0 when sampling from it, DirectX 1.0. So we always have in-shader
* conversion for this format. */
idx = get_format_idx(WINED3DFMT_R8G8_SNORM);
- gl_info->formats[idx].color_fixup = create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
idx = get_format_idx(WINED3DFMT_R16G16_SNORM);
- gl_info->formats[idx].color_fixup = create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
}
else
@@ -3434,40 +3437,40 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
/* Emulate using unsigned formats. This requires load-time conversion in addition to the
* fixups here. */
idx = get_format_idx(WINED3DFMT_R8G8_SNORM);
- gl_info->formats[idx].color_fixup = create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
idx = get_format_idx(WINED3DFMT_R16G16_SNORM);
- gl_info->formats[idx].color_fixup = create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
idx = get_format_idx(WINED3DFMT_R8G8B8A8_SNORM);
- gl_info->formats[idx].color_fixup = create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 1, CHANNEL_SOURCE_Z, 1, CHANNEL_SOURCE_W);
idx = get_format_idx(WINED3DFMT_R5G5_SNORM_L6_UNORM);
- gl_info->formats[idx].color_fixup = create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE);
}
if (!gl_info->supported[NV_TEXTURE_SHADER])
{
idx = get_format_idx(WINED3DFMT_R8G8_SNORM_L8X8_UNORM);
- gl_info->formats[idx].color_fixup = create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_W);
}
if (gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] || gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC])
{
idx = get_format_idx(WINED3DFMT_ATI1N);
- gl_info->formats[idx].color_fixup = create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X);
idx = get_format_idx(WINED3DFMT_ATI2N);
- gl_info->formats[idx].color_fixup = create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
}
else if (gl_info->supported[ATI_TEXTURE_COMPRESSION_3DC])
{
idx = get_format_idx(WINED3DFMT_ATI2N);
- gl_info->formats[idx].color_fixup= create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_W, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
}
@@ -3475,81 +3478,81 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
|| (gl_info->supported[ARB_FRAGMENT_SHADER] && gl_info->supported[ARB_VERTEX_SHADER])))
{
idx = get_format_idx(WINED3DFMT_YUY2);
- gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YUY2);
+ adapter->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YUY2);
idx = get_format_idx(WINED3DFMT_UYVY);
- gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_UYVY);
+ adapter->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_UYVY);
}
else if (!gl_info->supported[APPLE_YCBCR_422] && (!gl_info->supported[ARB_FRAGMENT_PROGRAM]
&& (!gl_info->supported[ARB_FRAGMENT_SHADER] || !gl_info->supported[ARB_VERTEX_SHADER])))
{
idx = get_format_idx(WINED3DFMT_YUY2);
- gl_info->formats[idx].glInternal = 0;
+ adapter->formats[idx].glInternal = 0;
idx = get_format_idx(WINED3DFMT_UYVY);
- gl_info->formats[idx].glInternal = 0;
+ adapter->formats[idx].glInternal = 0;
}
if (gl_info->supported[ARB_FRAGMENT_PROGRAM]
|| (gl_info->supported[ARB_FRAGMENT_SHADER] && gl_info->supported[ARB_VERTEX_SHADER]))
{
idx = get_format_idx(WINED3DFMT_YV12);
- format_set_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_HEIGHT_SCALE);
- gl_info->formats[idx].height_scale.numerator = 3;
- gl_info->formats[idx].height_scale.denominator = 2;
- gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YV12);
+ format_set_flag(&adapter->formats[idx], WINED3DFMT_FLAG_HEIGHT_SCALE);
+ adapter->formats[idx].height_scale.numerator = 3;
+ adapter->formats[idx].height_scale.denominator = 2;
+ adapter->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YV12);
idx = get_format_idx(WINED3DFMT_NV12);
- format_set_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_HEIGHT_SCALE);
- gl_info->formats[idx].height_scale.numerator = 3;
- gl_info->formats[idx].height_scale.denominator = 2;
- gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_NV12);
+ format_set_flag(&adapter->formats[idx], WINED3DFMT_FLAG_HEIGHT_SCALE);
+ adapter->formats[idx].height_scale.numerator = 3;
+ adapter->formats[idx].height_scale.denominator = 2;
+ adapter->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_NV12);
}
else
{
idx = get_format_idx(WINED3DFMT_YV12);
- gl_info->formats[idx].glInternal = 0;
+ adapter->formats[idx].glInternal = 0;
idx = get_format_idx(WINED3DFMT_NV12);
- gl_info->formats[idx].glInternal = 0;
+ adapter->formats[idx].glInternal = 0;
}
if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
{
idx = get_format_idx(WINED3DFMT_A8_UNORM);
- gl_info->formats[idx].color_fixup = create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_ZERO, 0, CHANNEL_SOURCE_ZERO, 0, CHANNEL_SOURCE_ZERO, 0, CHANNEL_SOURCE_X);
idx = get_format_idx(WINED3DFMT_L8A8_UNORM);
- gl_info->formats[idx].color_fixup = create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y);
idx = get_format_idx(WINED3DFMT_L4A4_UNORM);
- gl_info->formats[idx].color_fixup = create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y);
idx = get_format_idx(WINED3DFMT_L16_UNORM);
- gl_info->formats[idx].color_fixup = create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE);
idx = get_format_idx(WINED3DFMT_INTZ);
- gl_info->formats[idx].color_fixup = create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X);
}
if (gl_info->supported[ARB_TEXTURE_RG])
{
idx = get_format_idx(WINED3DFMT_L8_UNORM);
- gl_info->formats[idx].color_fixup = create_color_fixup_desc(
+ adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE);
}
if (gl_info->supported[ARB_FRAGMENT_PROGRAM] || gl_info->supported[ARB_FRAGMENT_SHADER])
{
idx = get_format_idx(WINED3DFMT_P8_UINT);
- gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_P8);
+ adapter->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_P8);
}
if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA])
{
idx = get_format_idx(WINED3DFMT_B8G8R8A8_UNORM);
- gl_info->formats[idx].gl_vtx_format = GL_BGRA;
+ adapter->formats[idx].gl_vtx_format = GL_BGRA;
}
if (!gl_info->supported[ARB_HALF_FLOAT_VERTEX])
@@ -3557,28 +3560,28 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
/* Do not change the size of the type, it is CPU side. We have to change the GPU-side information though.
* It is the job of the vertex buffer code to make sure that the vbos have the right format */
idx = get_format_idx(WINED3DFMT_R16G16_FLOAT);
- gl_info->formats[idx].gl_vtx_type = GL_FLOAT;
+ adapter->formats[idx].gl_vtx_type = GL_FLOAT;
idx = get_format_idx(WINED3DFMT_R16G16B16A16_FLOAT);
- gl_info->formats[idx].gl_vtx_type = GL_FLOAT;
+ adapter->formats[idx].gl_vtx_type = GL_FLOAT;
}
if (!gl_info->supported[ARB_HALF_FLOAT_PIXEL])
{
idx = get_format_idx(WINED3DFMT_R16_FLOAT);
- format_clear_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_TEXTURE);
+ format_clear_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE);
idx = get_format_idx(WINED3DFMT_R16G16_FLOAT);
- format_clear_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_TEXTURE);
+ format_clear_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE);
idx = get_format_idx(WINED3DFMT_R16G16B16A16_FLOAT);
- format_clear_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_TEXTURE);
+ format_clear_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE);
}
if (gl_info->quirks & WINED3D_QUIRK_BROKEN_RGBA16)
{
idx = get_format_idx(WINED3DFMT_R16G16B16A16_UNORM);
- format_clear_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_TEXTURE);
+ format_clear_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE);
}
/* ATI instancing hack: Although ATI cards do not support Shader Model
@@ -3597,7 +3600,7 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
if (gl_info->supported[ARB_VERTEX_PROGRAM] || gl_info->supported[ARB_VERTEX_SHADER])
{
idx = get_format_idx(WINED3DFMT_INST);
- format_set_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_TEXTURE);
+ format_set_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE);
}
/* Depth bound test. To query if the card supports it CheckDeviceFormat()
@@ -3609,7 +3612,7 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
if (gl_info->supported[EXT_DEPTH_BOUNDS_TEST])
{
idx = get_format_idx(WINED3DFMT_NVDB);
- format_set_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_TEXTURE);
+ format_set_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE);
}
/* RESZ aka AMD DX9-level hack for multisampled depth buffer resolve. You query for RESZ
@@ -3618,12 +3621,12 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
{
idx = get_format_idx(WINED3DFMT_RESZ);
- format_set_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_RENDERTARGET);
+ format_set_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_RENDERTARGET);
}
- for (i = 0; i < gl_info->format_count; ++i)
+ for (i = 0; i < adapter->format_count; ++i)
{
- struct wined3d_format *format = &gl_info->formats[i];
+ struct wined3d_format *format = &adapter->formats[i];
if (!(format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_TEXTURE))
continue;
@@ -3648,17 +3651,17 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
/* These formats are not supported for 3D textures. See also
* WINED3DFMT_FLAG_DECOMPRESS. */
idx = get_format_idx(WINED3DFMT_ATI1N);
- gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
+ adapter->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
idx = get_format_idx(WINED3DFMT_ATI2N);
- gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
+ adapter->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
idx = get_format_idx(WINED3DFMT_BC4_UNORM);
- gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
+ adapter->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
idx = get_format_idx(WINED3DFMT_BC4_SNORM);
- gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
+ adapter->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
idx = get_format_idx(WINED3DFMT_BC5_UNORM);
- gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
+ adapter->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
idx = get_format_idx(WINED3DFMT_BC5_SNORM);
- gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
+ adapter->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
}
static unsigned int calculate_vertex_attribute_size(GLenum type, unsigned int component_count)
@@ -3689,14 +3692,15 @@ static unsigned int calculate_vertex_attribute_size(GLenum type, unsigned int co
}
}
-static BOOL init_format_vertex_info(struct wined3d_gl_info *gl_info)
+static BOOL init_format_vertex_info(const struct wined3d_adapter *adapter,
+ struct wined3d_gl_info *gl_info)
{
struct wined3d_format *format;
unsigned int i;
for (i = 0; i < ARRAY_SIZE(format_vertex_info); ++i)
{
- if (!(format = get_format_internal(gl_info, format_vertex_info[i].id)))
+ if (!(format = get_format_internal(adapter, format_vertex_info[i].id)))
return FALSE;
if (!gl_info->supported[format_vertex_info[i].extension])
@@ -3719,7 +3723,7 @@ static BOOL init_format_vertex_info(struct wined3d_gl_info *gl_info)
return TRUE;
}
-static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info)
+static BOOL init_typeless_formats(const struct wined3d_adapter *adapter)
{
unsigned int flags[WINED3D_GL_RES_TYPE_COUNT];
unsigned int i, j;
@@ -3728,9 +3732,9 @@ static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info)
{
struct wined3d_format *format, *typeless_format;
- if (!(format = get_format_internal(gl_info, typed_formats[i].id)))
+ if (!(format = get_format_internal(adapter, typed_formats[i].id)))
return FALSE;
- if (!(typeless_format = get_format_internal(gl_info, typed_formats[i].typeless_id)))
+ if (!(typeless_format = get_format_internal(adapter, typed_formats[i].typeless_id)))
return FALSE;
memcpy(flags, typeless_format->flags, sizeof(flags));
@@ -3745,12 +3749,12 @@ static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info)
struct wined3d_format *depth_view_format, *stencil_view_format;
enum wined3d_format_id format_id;
- if (!(typeless_format = get_format_internal(gl_info, typeless_depth_stencil_formats[i].typeless_id)))
+ if (!(typeless_format = get_format_internal(adapter, typeless_depth_stencil_formats[i].typeless_id)))
return FALSE;
- if (!(ds_format = get_format_internal(gl_info, typeless_depth_stencil_formats[i].depth_stencil_id)))
+ if (!(ds_format = get_format_internal(adapter, typeless_depth_stencil_formats[i].depth_stencil_id)))
return FALSE;
- typeless_ds_format = &gl_info->formats[WINED3D_FORMAT_COUNT + i];
+ typeless_ds_format = &adapter->formats[WINED3D_FORMAT_COUNT + i];
typeless_ds_format->id = typeless_depth_stencil_formats[i].typeless_id;
copy_format(typeless_ds_format, ds_format);
for (j = 0; j < ARRAY_SIZE(typeless_ds_format->flags); ++j)
@@ -3762,13 +3766,13 @@ static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info)
if ((format_id = typeless_depth_stencil_formats[i].depth_view_id)
&& typeless_depth_stencil_formats[i].separate_depth_view_format)
{
- if (!(depth_view_format = get_format_internal(gl_info, format_id)))
+ if (!(depth_view_format = get_format_internal(adapter, format_id)))
return FALSE;
copy_format(depth_view_format, ds_format);
}
if ((format_id = typeless_depth_stencil_formats[i].stencil_view_id))
{
- if (!(stencil_view_format = get_format_internal(gl_info, format_id)))
+ if (!(stencil_view_format = get_format_internal(adapter, format_id)))
return FALSE;
copy_format(stencil_view_format, ds_format);
}
@@ -3777,16 +3781,17 @@ static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info)
return TRUE;
}
-static void init_format_gen_mipmap_info(struct wined3d_gl_info *gl_info)
+static void init_format_gen_mipmap_info(const struct wined3d_adapter *adapter,
+ struct wined3d_gl_info *gl_info)
{
unsigned int i, j;
if (!gl_info->fbo_ops.glGenerateMipmap)
return;
- for (i = 0; i < gl_info->format_count; ++i)
+ for (i = 0; i < adapter->format_count; ++i)
{
- struct wined3d_format *format = &gl_info->formats[i];
+ struct wined3d_format *format = &adapter->formats[i];
for (j = 0; j < ARRAY_SIZE(format->flags); ++j)
if (!(~format->flags[j] & (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FILTERING)))
@@ -3935,15 +3940,15 @@ static float wined3d_adapter_find_polyoffset_scale(struct wined3d_caps_gl_ctx *c
return (float)(1u << cur);
}
-static void init_format_depth_bias_scale(struct wined3d_caps_gl_ctx *ctx,
- const struct wined3d_d3d_info *d3d_info)
+static void init_format_depth_bias_scale(struct wined3d_adapter *adapter,
+ struct wined3d_caps_gl_ctx *ctx)
{
- const struct wined3d_gl_info *gl_info = ctx->gl_info;
+ const struct wined3d_d3d_info *d3d_info = &adapter->d3d_info;
unsigned int i;
- for (i = 0; i < gl_info->format_count; ++i)
+ for (i = 0; i < adapter->format_count; ++i)
{
- struct wined3d_format *format = &gl_info->formats[i];
+ struct wined3d_format *format = &adapter->formats[i];
if (format->flags[WINED3D_GL_RES_TYPE_RB] & WINED3DFMT_FLAG_DEPTH)
{
@@ -3969,35 +3974,34 @@ BOOL wined3d_adapter_init_format_info(struct wined3d_adapter *adapter, struct wi
{
struct wined3d_gl_info *gl_info = &adapter->gl_info;
- if (!init_format_base_info(gl_info)) return FALSE;
- if (!init_format_block_info(gl_info)) goto fail;
- if (!init_format_decompress_info(gl_info)) goto fail;
+ if (!init_format_base_info(adapter)) return FALSE;
+ if (!init_format_block_info(adapter)) goto fail;
+ if (!init_format_decompress_info(adapter)) goto fail;
if (!ctx) /* WINED3D_NO3D */
return TRUE;
if (!init_format_texture_info(adapter, gl_info)) goto fail;
- if (!init_format_vertex_info(gl_info)) goto fail;
+ if (!init_format_vertex_info(adapter, gl_info)) goto fail;
apply_format_fixups(adapter, gl_info);
- init_format_fbo_compat_info(ctx);
- init_format_filter_info(gl_info, adapter->driver_info.vendor);
- if (!init_typeless_formats(gl_info)) goto fail;
- init_format_gen_mipmap_info(gl_info);
- init_format_depth_bias_scale(ctx, &adapter->d3d_info);
+ init_format_fbo_compat_info(adapter, ctx);
+ init_format_filter_info(adapter, gl_info);
+ if (!init_typeless_formats(adapter)) goto fail;
+ init_format_gen_mipmap_info(adapter, gl_info);
+ init_format_depth_bias_scale(adapter, ctx);
return TRUE;
fail:
- heap_free(gl_info->formats);
- gl_info->formats = NULL;
+ heap_free(adapter->formats);
+ adapter->formats = NULL;
return FALSE;
}
const struct wined3d_format *wined3d_get_format(const struct wined3d_adapter *adapter,
enum wined3d_format_id format_id, unsigned int resource_usage)
{
- const struct wined3d_gl_info *gl_info = &adapter->gl_info;
const struct wined3d_format *format;
int idx = get_format_idx(format_id);
unsigned int i;
@@ -4006,22 +4010,22 @@ const struct wined3d_format *wined3d_get_format(const struct wined3d_adapter *ad
{
FIXME("Can't find format %s (%#x) in the format lookup table.\n",
debug_d3dformat(format_id), format_id);
- return &gl_info->formats[get_format_idx(WINED3DFMT_UNKNOWN)];
+ return &adapter->formats[get_format_idx(WINED3DFMT_UNKNOWN)];
}
- format = &gl_info->formats[idx];
+ format = &adapter->formats[idx];
if (resource_usage & WINED3DUSAGE_DEPTHSTENCIL && wined3d_format_is_typeless(format))
{
for (i = 0; i < ARRAY_SIZE(typeless_depth_stencil_formats); ++i)
{
if (typeless_depth_stencil_formats[i].typeless_id == format_id)
- return &gl_info->formats[WINED3D_FORMAT_COUNT + i];
+ return &adapter->formats[WINED3D_FORMAT_COUNT + i];
}
FIXME("Cannot find depth/stencil typeless format %s (%#x).\n",
debug_d3dformat(format_id), format_id);
- return &gl_info->formats[get_format_idx(WINED3DFMT_UNKNOWN)];
+ return &adapter->formats[get_format_idx(WINED3DFMT_UNKNOWN)];
}
return format;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index da3cd4615686..70841683e5ba 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2599,9 +2599,6 @@ struct wined3d_gl_info
HGLRC (WINAPI *p_wglCreateContextAttribsARB)(HDC dc, HGLRC share, const GLint *attribs);
struct opengl_funcs gl_ops;
struct wined3d_fbo_ops fbo_ops;
-
- struct wined3d_format *formats;
- unsigned int format_count;
};
/* The driver names reflect the lowest GPU supported
@@ -2682,6 +2679,9 @@ struct wined3d_adapter
UINT64 vram_bytes_used;
LUID luid;
+ struct wined3d_format *formats;
+ unsigned int format_count;
+
const struct wined3d_vertex_pipe_ops *vertex_pipe;
const struct fragment_pipeline *fragment_pipe;
const struct wined3d_shader_backend_ops *shader_backend;
--
2.16.4
Aug. 30, 2018
Re: [PATCH 3/3] shell32/autocomplete: Revamp pwzsRegKeyPath handling so it can deal with arbitrary sizes and make it more robust
by Alexandre Julliard
Gabriel Ivăncescu <gabrielopcode(a)gmail.com> writes:
> On Thu, Aug 30, 2018 at 2:50 PM, Alexandre Julliard <julliard(a)winehq.org> wrote:
>> Gabriel Ivăncescu <gabrielopcode(a)gmail.com> writes:
>>
>> There can still be a race, only you are making the function fail in that
>> case, that's not nice behavior. The right way to do that sort of thing
>> is to allocate a reasonable buffer, get the string (without querying the
>> length first), and on overflow restart the loop with a larger buffer.
>>
>
> Okay, you are right. I'll have it get the length first (because this
> simplifies the case where the value doesn't exist in HKCU but it does
> in HKLM), and start with that buffer size, then use a loop until it
> returns success (or some error other than ERROR_MORE_DATA) or its type
> is not REG_SZ (this should be a failure, right?).
You should never be getting the length first. Just get the data right
away.
>> The Wine implementation replicates the Windows behavior, based on test
>> cases. That's more reliable than MSDN.
>
> Yes you are correct but some hooks (like madCodeHook used in jauntePE)
> might hook the registry APIs to provide virtualized redirections. They
> *might* follow the MSDN instead of test-cases, because that's what
> MSDN claims, I really have no idea if they'll return a non-NUL
> terminated string though.
If anybody is implementing API hooking based only on MSDN descriptions,
they are in for a lot of trouble ;-)
--
Alexandre Julliard
julliard(a)winehq.org
Aug. 30, 2018
Re: [PATCH 3/3] shell32/autocomplete: Revamp pwzsRegKeyPath handling so it can deal with arbitrary sizes and make it more robust
by Gabriel Ivăncescu
On Thu, Aug 30, 2018 at 2:50 PM, Alexandre Julliard <julliard(a)winehq.org> wrote:
> Gabriel Ivăncescu <gabrielopcode(a)gmail.com> writes:
>
> There can still be a race, only you are making the function fail in that
> case, that's not nice behavior. The right way to do that sort of thing
> is to allocate a reasonable buffer, get the string (without querying the
> length first), and on overflow restart the loop with a larger buffer.
>
Okay, you are right. I'll have it get the length first (because this
simplifies the case where the value doesn't exist in HKCU but it does
in HKLM), and start with that buffer size, then use a loop until it
returns success (or some error other than ERROR_MORE_DATA) or its type
is not REG_SZ (this should be a failure, right?).
>
> The Wine implementation replicates the Windows behavior, based on test
> cases. That's more reliable than MSDN.
>
Yes you are correct but some hooks (like madCodeHook used in jauntePE)
might hook the registry APIs to provide virtualized redirections. They
*might* follow the MSDN instead of test-cases, because that's what
MSDN claims, I really have no idea if they'll return a non-NUL
terminated string though. Was just playing it safe. At the very least,
should I just forcefully NUL terminate the buffer? (without increasing
its size by +1) It would only be a single extra store and doesn't do
anything on an already NUL terminated buffer.
Aug. 30, 2018
[PATCH vkd3d 3/3] vkd3d: Return bool from vkd3d_create_texture_view().
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
For consistency with vkd3d_create_buffer_view().
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d/resource.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c
index 4772b3f10dbf..219b95c37194 100644
--- a/libs/vkd3d/resource.c
+++ b/libs/vkd3d/resource.c
@@ -1341,7 +1341,7 @@ static bool init_default_texture_view_desc(struct vkd3d_texture_view_desc *desc,
return true;
}
-static HRESULT vkd3d_create_texture_view(struct d3d12_device *device,
+static bool vkd3d_create_texture_view(struct d3d12_device *device,
struct d3d12_resource *resource, const struct vkd3d_texture_view_desc *desc,
struct vkd3d_view **view)
{
@@ -1369,18 +1369,18 @@ static HRESULT vkd3d_create_texture_view(struct d3d12_device *device,
if ((vr = VK_CALL(vkCreateImageView(device->vk_device, &view_desc, NULL, &vk_view))) < 0)
{
WARN("Failed to create Vulkan image view, vr %d.\n", vr);
- return hresult_from_vk_result(vr);
+ return false;
}
if (!(object = vkd3d_view_create()))
{
VK_CALL(vkDestroyImageView(device->vk_device, vk_view, NULL));
- return E_OUTOFMEMORY;
+ return false;
}
object->u.vk_image_view = vk_view;
*view = object;
- return S_OK;
+ return true;
}
void d3d12_desc_create_cbv(struct d3d12_desc *descriptor,
@@ -1541,7 +1541,7 @@ void d3d12_desc_create_srv(struct d3d12_desc *descriptor,
}
}
- if (FAILED(vkd3d_create_texture_view(device, resource, &vkd3d_desc, &view)))
+ if (!vkd3d_create_texture_view(device, resource, &vkd3d_desc, &view))
return;
descriptor->magic = VKD3D_DESCRIPTOR_MAGIC_SRV;
@@ -1663,7 +1663,7 @@ static void vkd3d_create_texture_uav(struct d3d12_desc *descriptor,
}
}
- if (FAILED(vkd3d_create_texture_view(device, resource, &vkd3d_desc, &view)))
+ if (!vkd3d_create_texture_view(device, resource, &vkd3d_desc, &view))
return;
descriptor->magic = VKD3D_DESCRIPTOR_MAGIC_UAV;
@@ -1913,7 +1913,7 @@ void d3d12_rtv_desc_create_rtv(struct d3d12_rtv_desc *rtv_desc, struct d3d12_dev
vkd3d_desc.layer_count = resource->desc.DepthOrArraySize;
}
- if (FAILED(vkd3d_create_texture_view(device, resource, &vkd3d_desc, &view)))
+ if (!vkd3d_create_texture_view(device, resource, &vkd3d_desc, &view))
return;
rtv_desc->magic = VKD3D_DESCRIPTOR_MAGIC_RTV;
@@ -1985,7 +1985,7 @@ void d3d12_dsv_desc_create_dsv(struct d3d12_dsv_desc *dsv_desc, struct d3d12_dev
}
}
- if (FAILED(vkd3d_create_texture_view(device, resource, &vkd3d_desc, &view)))
+ if (!vkd3d_create_texture_view(device, resource, &vkd3d_desc, &view))
return;
dsv_desc->magic = VKD3D_DESCRIPTOR_MAGIC_DSV;
--
2.16.4
Aug. 30, 2018
[PATCH vkd3d 2/3] vkd3d: Create vkd3d_views in vkd3d_create_buffer_view().
by Józef Kucia
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d/resource.c | 44 +++++++++++++++++++++++---------------------
1 file changed, 23 insertions(+), 21 deletions(-)
diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c
index 7dc7b384b57e..4772b3f10dbf 100644
--- a/libs/vkd3d/resource.c
+++ b/libs/vkd3d/resource.c
@@ -1206,10 +1206,13 @@ static bool vkd3d_create_vk_buffer_view(struct d3d12_device *device,
static bool vkd3d_create_buffer_view(struct d3d12_device *device,
struct d3d12_resource *resource, DXGI_FORMAT view_format,
unsigned int offset, unsigned int size, unsigned int structure_stride,
- unsigned int flags, VkBufferView *vk_view)
+ unsigned int flags, struct vkd3d_view **view)
{
+ const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
const struct vkd3d_format *format;
+ struct vkd3d_view *object;
unsigned int element_size;
+ VkBufferView vk_view;
if (view_format == DXGI_FORMAT_R32_TYPELESS && (flags & VKD3D_VIEW_RAW_BUFFER))
{
@@ -1231,8 +1234,19 @@ static bool vkd3d_create_buffer_view(struct d3d12_device *device,
return false;
}
- return vkd3d_create_vk_buffer_view(device, resource, format,
- offset * element_size, size * element_size, vk_view);
+ if (!vkd3d_create_vk_buffer_view(device, resource, format,
+ offset * element_size, size * element_size, &vk_view))
+ return false;
+
+ if (!(object = vkd3d_view_create()))
+ {
+ VK_CALL(vkDestroyBufferView(device->vk_device, vk_view, NULL));
+ return false;
+ }
+
+ object->u.vk_buffer_view = vk_view;
+ *view = object;
+ return true;
}
static void vkd3d_set_view_swizzle_for_format(VkComponentMapping *components,
@@ -1419,6 +1433,7 @@ static void vkd3d_create_buffer_srv(struct d3d12_desc *descriptor,
const D3D12_SHADER_RESOURCE_VIEW_DESC *desc)
{
struct vkd3d_view *view;
+ unsigned int flags;
if (!desc)
{
@@ -1432,18 +1447,11 @@ static void vkd3d_create_buffer_srv(struct d3d12_desc *descriptor,
return;
}
- if (!(view = vkd3d_view_create()))
- return;
-
+ flags = vkd3d_view_flags_from_d3d12_buffer_srv_flags(desc->u.Buffer.Flags);
if (!vkd3d_create_buffer_view(device, resource, desc->Format,
desc->u.Buffer.FirstElement, desc->u.Buffer.NumElements,
- desc->u.Buffer.StructureByteStride,
- vkd3d_view_flags_from_d3d12_buffer_srv_flags(desc->u.Buffer.Flags),
- &view->u.vk_buffer_view))
- {
- vkd3d_free(view);
+ desc->u.Buffer.StructureByteStride, flags, &view))
return;
- }
descriptor->magic = VKD3D_DESCRIPTOR_MAGIC_SRV;
descriptor->vk_descriptor_type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
@@ -1555,6 +1563,7 @@ static void vkd3d_create_buffer_uav(struct d3d12_desc *descriptor, struct d3d12_
const D3D12_UNORDERED_ACCESS_VIEW_DESC *desc)
{
struct vkd3d_view *view;
+ unsigned int flags;
if (!desc)
{
@@ -1571,18 +1580,11 @@ static void vkd3d_create_buffer_uav(struct d3d12_desc *descriptor, struct d3d12_
if (desc->u.Buffer.CounterOffsetInBytes)
FIXME("Ignoring counter offset %"PRIu64".\n", desc->u.Buffer.CounterOffsetInBytes);
- if (!(view = vkd3d_view_create()))
- return;
-
+ flags = vkd3d_view_flags_from_d3d12_buffer_uav_flags(desc->u.Buffer.Flags);
if (!vkd3d_create_buffer_view(device, resource, desc->Format,
desc->u.Buffer.FirstElement, desc->u.Buffer.NumElements,
- desc->u.Buffer.StructureByteStride,
- vkd3d_view_flags_from_d3d12_buffer_uav_flags(desc->u.Buffer.Flags),
- &view->u.vk_buffer_view))
- {
- vkd3d_free(view);
+ desc->u.Buffer.StructureByteStride, flags, &view))
return;
- }
descriptor->magic = VKD3D_DESCRIPTOR_MAGIC_UAV;
descriptor->vk_descriptor_type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER;
--
2.16.4
Aug. 30, 2018