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
September 2018
- 70 participants
- 1549 messages
[PATCH v3 5/5] shell32/tests: Test hijacking the edit control's procedure after AutoComplete
by Gabriel Ivăncescu
Windows' AutoComplete seems to bypass hijacking in some cases. However,
WM_GETTEXT seems to be able to get hijacked.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com>
---
This still works now with Wine, so I think it's nice to add these tests
just in case for the future.
Also reduced the Sleep amount to 1/3 of its original, which will be especially
useful in future tests (to be added) to prevent them from taking way too long.
dlls/shell32/tests/autocomplete.c | 82 +++++++++++++++++++++++++++++++++++----
1 file changed, 75 insertions(+), 7 deletions(-)
diff --git a/dlls/shell32/tests/autocomplete.c b/dlls/shell32/tests/autocomplete.c
index b9c6374..e85e30c 100644
--- a/dlls/shell32/tests/autocomplete.c
+++ b/dlls/shell32/tests/autocomplete.c
@@ -236,6 +236,36 @@ static void createMainWnd(void)
CW_USEDEFAULT, CW_USEDEFAULT, 130, 105, NULL, NULL, GetModuleHandleA(NULL), 0);
}
+static WNDPROC HijackerWndProc_prev;
+static const WCHAR HijackerWndProc_txt[] = {'H','i','j','a','c','k','e','d',0};
+static LRESULT CALLBACK HijackerWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case WM_GETTEXT:
+ {
+ size_t len = min(wParam, ARRAY_SIZE(HijackerWndProc_txt));
+ memcpy((void*)lParam, HijackerWndProc_txt, len * sizeof(WCHAR));
+ return len;
+ }
+ case WM_GETTEXTLENGTH:
+ return ARRAY_SIZE(HijackerWndProc_txt) - 1;
+ }
+ return CallWindowProcW(HijackerWndProc_prev, hWnd, msg, wParam, lParam);
+}
+
+static LRESULT CALLBACK HijackerWndProc2(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case EM_SETSEL:
+ lParam = wParam;
+ break;
+ case WM_SETTEXT:
+ lParam = (LPARAM)HijackerWndProc_txt;
+ break;
+ }
+ return CallWindowProcW(HijackerWndProc_prev, hWnd, msg, wParam, lParam);
+}
+
struct string_enumerator
{
IEnumString IEnumString_iface;
@@ -358,18 +388,29 @@ static HRESULT string_enumerator_create(void **ppv, WCHAR **suggestions, int cou
return S_OK;
}
+static void dispatch_messages(void)
+{
+ MSG msg;
+ Sleep(33);
+ while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&msg);
+ DispatchMessageA(&msg);
+ }
+}
+
static void test_custom_source(void)
{
static WCHAR str_alpha[] = {'t','e','s','t','1',0};
static WCHAR str_alpha2[] = {'t','e','s','t','2',0};
static WCHAR str_beta[] = {'a','u','t','o',' ','c','o','m','p','l','e','t','e',0};
+ static WCHAR str_au[] = {'a','u',0};
static WCHAR *suggestions[] = { str_alpha, str_alpha2, str_beta };
IUnknown *enumerator;
IAutoComplete2 *autocomplete;
HWND hwnd_edit;
WCHAR buffer[20];
HRESULT hr;
- MSG msg;
ShowWindow(hMainWnd, SW_SHOW);
@@ -385,16 +426,43 @@ static void test_custom_source(void)
hr = IAutoComplete2_Init(autocomplete, hwnd_edit, enumerator, NULL, NULL);
ok(hr == S_OK, "IAutoComplete_Init failed: %x\n", hr);
+ SetFocus(hwnd_edit);
SendMessageW(hwnd_edit, WM_CHAR, 'a', 1);
SendMessageW(hwnd_edit, WM_CHAR, 'u', 1);
- Sleep(100);
- while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
- {
- TranslateMessage(&msg);
- DispatchMessageA(&msg);
- }
+ dispatch_messages();
+ SendMessageW(hwnd_edit, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer);
+ ok(lstrcmpW(str_beta, buffer) == 0, "Expected %s, got %s\n", wine_dbgstr_w(str_beta), wine_dbgstr_w(buffer));
+ SendMessageW(hwnd_edit, EM_SETSEL, 0, -1);
+ SendMessageW(hwnd_edit, WM_CHAR, '\b', 1);
+ dispatch_messages();
+ SendMessageW(hwnd_edit, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer);
+ ok(buffer[0] == '\0', "Expected empty string, got %s\n", wine_dbgstr_w(buffer));
+
+ /* hijack the window procedure */
+ HijackerWndProc_prev = (WNDPROC)SetWindowLongPtrW(hwnd_edit, GWLP_WNDPROC, (LONG_PTR)HijackerWndProc);
+ SendMessageW(hwnd_edit, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer);
+ ok(lstrcmpW(HijackerWndProc_txt, buffer) == 0, "Expected %s, got %s\n", wine_dbgstr_w(HijackerWndProc_txt), wine_dbgstr_w(buffer));
+
+ SendMessageW(hwnd_edit, WM_CHAR, 'a', 1);
+ SendMessageW(hwnd_edit, WM_CHAR, 'u', 1);
+ SetWindowLongPtrW(hwnd_edit, GWLP_WNDPROC, (LONG_PTR)HijackerWndProc_prev);
+ dispatch_messages();
+ SendMessageW(hwnd_edit, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer);
+ ok(lstrcmpW(str_au, buffer) == 0, "Expected %s, got %s\n", wine_dbgstr_w(str_au), wine_dbgstr_w(buffer));
+ SendMessageW(hwnd_edit, EM_SETSEL, 0, -1);
+ SendMessageW(hwnd_edit, WM_CHAR, '\b', 1);
+ dispatch_messages();
+ SendMessageW(hwnd_edit, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer);
+ ok(buffer[0] == '\0', "Expected empty string, got %s\n", wine_dbgstr_w(buffer));
+
+ HijackerWndProc_prev = (WNDPROC)SetWindowLongPtrW(hwnd_edit, GWLP_WNDPROC, (LONG_PTR)HijackerWndProc2);
+ SendMessageW(hwnd_edit, WM_CHAR, 'a', 1);
+ SendMessageW(hwnd_edit, WM_CHAR, 'u', 1);
+ SetWindowLongPtrW(hwnd_edit, GWLP_WNDPROC, (LONG_PTR)HijackerWndProc_prev);
+ dispatch_messages();
SendMessageW(hwnd_edit, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer);
ok(lstrcmpW(str_beta, buffer) == 0, "Expected %s, got %s\n", wine_dbgstr_w(str_beta), wine_dbgstr_w(buffer));
+ /* end of hijacks */
ShowWindow(hMainWnd, SW_HIDE);
DestroyWindow(hwnd_edit);
--
1.9.1
Sept. 22, 2018
[PATCH v3 4/5] shell32/autocomplete: Pass hwnd for consistency with the other calls
by Gabriel Ivăncescu
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com>
---
dlls/shell32/autocomplete.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c
index 1751401..2153968 100644
--- a/dlls/shell32/autocomplete.c
+++ b/dlls/shell32/autocomplete.c
@@ -409,7 +409,7 @@ static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
sel = SendMessageW(hwnd, LB_GETCURSEL, 0, 0);
if (sel < 0)
break;
- len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, 0);
+ len = SendMessageW(hwnd, LB_GETTEXTLEN, sel, 0);
if (!(msg = heap_alloc((len + 1) * sizeof(WCHAR))))
break;
len = SendMessageW(hwnd, LB_GETTEXT, sel, (LPARAM)msg);
--
1.9.1
Sept. 22, 2018
[PATCH v3 3/5] shell32/autocomplete: Handle WM_SETTEXT for autocompletion
by Gabriel Ivăncescu
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com>
---
This should work now that we send it directly to the edit control's procedure.
dlls/shell32/autocomplete.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c
index 2f63d88..1751401 100644
--- a/dlls/shell32/autocomplete.c
+++ b/dlls/shell32/autocomplete.c
@@ -370,6 +370,7 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
autocomplete_text(This, hwnd, (This->options & ACO_AUTOAPPEND) && wParam >= ' '
? autoappend_flag_yes : autoappend_flag_no);
return ret;
+ case WM_SETTEXT:
case WM_CUT:
case WM_CLEAR:
case WM_UNDO:
--
1.9.1
Sept. 22, 2018
[PATCH v3 2/5] shell32/autocomplete: Send some messages directly to the edit control's procedure
by Gabriel Ivăncescu
Send some of the messages directly to the edit control's window procedure
to match Windows behavior and to be able to process WM_SETTEXT.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com>
---
v3: Keep SendMessage when retrieving the text.
dlls/shell32/autocomplete.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c
index 048a47f..2f63d88 100644
--- a/dlls/shell32/autocomplete.c
+++ b/dlls/shell32/autocomplete.c
@@ -100,6 +100,14 @@ static inline IAutoCompleteImpl *impl_from_IAutoCompleteDropDown(IAutoCompleteDr
return CONTAINING_RECORD(iface, IAutoCompleteImpl, IAutoCompleteDropDown_iface);
}
+static void set_text_and_selection(IAutoCompleteImpl *ac, HWND hwnd, WCHAR *text, WPARAM start, LPARAM end)
+{
+ /* Send it directly to the edit control to match Windows behavior */
+ WNDPROC proc = ac->wpOrigEditProc;
+ if (CallWindowProcW(proc, hwnd, WM_SETTEXT, 0, (LPARAM)text))
+ CallWindowProcW(proc, hwnd, EM_SETSEL, start, end);
+}
+
static size_t format_quick_complete(WCHAR *dst, const WCHAR *qc, const WCHAR *str, size_t str_len)
{
/* Replace the first %s directly without using snprintf, to avoid
@@ -142,8 +150,7 @@ static void autoappend_str(IAutoCompleteImpl *ac, WCHAR *text, UINT len, WCHAR *
}
else tmp = str;
- SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)tmp);
- SendMessageW(hwnd, EM_SETSEL, len, size - 1);
+ set_text_and_selection(ac, hwnd, tmp, len, size - 1);
if (tmp != str)
heap_free(tmp);
}
@@ -256,8 +263,7 @@ static LRESULT ACEditSubclassProc_KeyDown(IAutoCompleteImpl *ac, HWND hwnd, UINT
if ((buf = heap_alloc(sz * sizeof(WCHAR))))
{
len = format_quick_complete(buf, ac->quickComplete, text, len);
- SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)buf);
- SendMessageW(hwnd, EM_SETSEL, 0, len);
+ set_text_and_selection(ac, hwnd, buf, 0, len);
heap_free(buf);
}
@@ -309,16 +315,13 @@ static LRESULT ACEditSubclassProc_KeyDown(IAutoCompleteImpl *ac, HWND hwnd, UINT
if (!(msg = heap_alloc((len + 1) * sizeof(WCHAR))))
return 0;
len = SendMessageW(ac->hwndListBox, LB_GETTEXT, sel, (LPARAM)msg);
- SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)msg);
- SendMessageW(hwnd, EM_SETSEL, len, len);
+ set_text_and_selection(ac, hwnd, msg, len, len);
heap_free(msg);
}
else
{
- UINT len;
- SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)ac->txtbackup);
- len = strlenW(ac->txtbackup);
- SendMessageW(hwnd, EM_SETSEL, len, len);
+ UINT len = strlenW(ac->txtbackup);
+ set_text_and_selection(ac, hwnd, ac->txtbackup, len, len);
}
return 0;
}
@@ -409,8 +412,7 @@ static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
if (!(msg = heap_alloc((len + 1) * sizeof(WCHAR))))
break;
len = SendMessageW(hwnd, LB_GETTEXT, sel, (LPARAM)msg);
- SendMessageW(This->hwndEdit, WM_SETTEXT, 0, (LPARAM)msg);
- SendMessageW(This->hwndEdit, EM_SETSEL, 0, len);
+ set_text_and_selection(This, This->hwndEdit, msg, 0, len);
ShowWindow(hwnd, SW_HIDE);
heap_free(msg);
break;
--
1.9.1
Sept. 22, 2018
[PATCH v3 1/5] shell32/autocomplete: Don't autocomplete at all on most control characters
by Gabriel Ivăncescu
Most control characters sent via some CTRL+key combination should not
autocomplete at all. ^C is one example, where just copying some text should
not show the auto-suggestion box (if not visible). ^V is another example,
where it is already handled in WM_PASTE, so it has to be a no-op here,
else auto-append from WM_PASTE would complete the text and then the ^V
autocompletion would remove every other suggestion in the listbox.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com>
---
v3: Use iscntrlW
dlls/shell32/autocomplete.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c
index ef835b9..048a47f 100644
--- a/dlls/shell32/autocomplete.c
+++ b/dlls/shell32/autocomplete.c
@@ -359,6 +359,10 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
return ACEditSubclassProc_KeyDown(This, hwnd, uMsg, wParam, lParam);
case WM_CHAR:
case WM_UNICHAR:
+ /* Don't autocomplete at all on most control characters */
+ if (iscntrlW(wParam) && !(wParam >= '\b' && wParam <= '\r'))
+ break;
+
ret = CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
autocomplete_text(This, hwnd, (This->options & ACO_AUTOAPPEND) && wParam >= ' '
? autoappend_flag_yes : autoappend_flag_no);
--
1.9.1
Sept. 22, 2018
Re: [PATCH] wininet/tests: Skip tests when querying INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT fails (newer win10)
by André Hentschel
Am 18.09.2018 um 20:29 schrieb Marvin:
> Hi,
>
> While running your changed tests on Windows, I think I found new failures.
> Being a bot and all I'm not very good at pattern recognition, so I might be
> wrong, but could you please double-check?
>
> Full results can be found at:
> https://testbot.winehq.org/JobDetails.pl?Key=42197
>
> Your paranoid android.
>
>
> === w2003std (32 bit Windows report) ===
>
> wininet:
> http.c:6021: Test failed: HttpSendRequest failed: 12045
> http.c:6822: Test failed: HttpSendRequest failed with error 12045
>
preexisting: https://test.winehq.org/data/tests/wininet:http.html
Sept. 22, 2018
Re: [PATCH] wine.inf: Add a ProfileList\<UserSID> registry subkey.
by Alexandre Julliard
Alex Henrie <alexhenrie24(a)gmail.com> writes:
> On Fri, Sep 21, 2018 at 10:47 AM Alexandre Julliard <julliard(a)winehq.org> wrote:
>>
>> Alex Henrie <alexhenrie24(a)gmail.com> writes:
>>
>> > @@ -527,6 +527,8 @@ HKLM,%CurrentVersionNT%\Perflib,,16
>> > HKLM,%CurrentVersionNT%\Ports,,16
>> > HKLM,%CurrentVersionNT%\Print,,16
>> > HKLM,%CurrentVersionNT%\ProfileList,,16
>> > +; Update/Replace if local_user_sid in server/token.c changes
>> > +HKLM,%CurrentVersionNT%\ProfileList\S-1-5-21-0-0-0-1000,,16
>>
>> It would be better to create this dynamically in some appropriate place
>> instead of hardcoding the SID in wine.inf.
>
> OK. Is wineboot the right place to create this key?
It's probably good enough for now, yes.
--
Alexandre Julliard
julliard(a)winehq.org
Sept. 22, 2018
Re: [PATCH 2/5] d3d9/tests: Properly check whether creating a device succeeded in test_flip().
by Marvin
Hi,
While running your changed tests on Windows, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at:
https://testbot.winehq.org/JobDetails.pl?Key=42372
Your paranoid android.
=== w864 (64 bit Windows report) ===
d3d9:
visual.c:8620: Test failed: Got unexpected color 0x0000ff00 for quad 2 (different colors).
Sept. 22, 2018
[PATCH 5/5] wined3d: Move the OpenGL texture format to struct wined3d_format_gl.
by Henri Verbeet
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/context.c | 4 +-
dlls/wined3d/surface.c | 48 ++--
dlls/wined3d/texture.c | 93 ++++----
dlls/wined3d/utils.c | 485 +++++++++++++++++++++--------------------
dlls/wined3d/view.c | 30 +--
dlls/wined3d/wined3d_private.h | 11 +-
6 files changed, 349 insertions(+), 322 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 167241a6f0f..8199afa1d0e 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -3868,6 +3868,7 @@ static void context_bind_unordered_access_views(struct wined3d_context *context,
{
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_unordered_access_view *view;
+ const struct wined3d_format_gl *format_gl;
GLuint texture_name;
unsigned int i;
GLint level;
@@ -3903,8 +3904,9 @@ static void context_bind_unordered_access_views(struct wined3d_context *context,
continue;
}
+ format_gl = wined3d_format_gl(view->format);
GL_EXTCALL(glBindImageTexture(i, texture_name, level, GL_TRUE, 0, GL_READ_WRITE,
- view->format->glInternal));
+ format_gl->internal));
if (view->counter_bo)
GL_EXTCALL(glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, i, view->counter_bo));
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index d1847bea34e..8b69720693e 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -348,22 +348,24 @@ static BOOL fbo_blitter_supported(enum wined3d_blit_op blit_op, const struct win
static void texture2d_download_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
const struct wined3d_context *context, DWORD dst_location)
{
- const struct wined3d_format *format = texture->resource.format;
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_texture_sub_resource *sub_resource;
unsigned int dst_row_pitch, dst_slice_pitch;
unsigned int src_row_pitch, src_slice_pitch;
+ const struct wined3d_format_gl *format_gl;
struct wined3d_bo_address data;
BYTE *temporary_mem = NULL;
unsigned int level;
GLenum target;
void *mem;
+ format_gl = wined3d_format_gl(texture->resource.format);
+
/* Only support read back of converted P8 textures. */
- if (texture->flags & WINED3D_TEXTURE_CONVERTED && format->id != WINED3DFMT_P8_UINT && !format->download)
+ if (texture->flags & WINED3D_TEXTURE_CONVERTED && format_gl->f.id != WINED3DFMT_P8_UINT && !format_gl->f.download)
{
ERR("Trying to read back converted texture %p, %u with format %s.\n",
- texture, sub_resource_idx, debug_d3dformat(format->id));
+ texture, sub_resource_idx, debug_d3dformat(format_gl->f.id));
return;
}
@@ -373,7 +375,7 @@ static void texture2d_download_data(struct wined3d_texture *texture, unsigned in
if (target == GL_TEXTURE_2D_ARRAY)
{
- if (format->download)
+ if (format_gl->f.download)
{
FIXME("Reading back converted array texture %p is not supported.\n", texture);
return;
@@ -396,14 +398,14 @@ static void texture2d_download_data(struct wined3d_texture *texture, unsigned in
if (texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
{
- if (format->download)
+ if (format_gl->f.download)
{
FIXME("Reading back converted texture %p with NP2 emulation is not supported.\n", texture);
return;
}
wined3d_texture_get_pitch(texture, level, &dst_row_pitch, &dst_slice_pitch);
- wined3d_format_calculate_pitch(format, texture->resource.device->surface_alignment,
+ wined3d_format_calculate_pitch(&format_gl->f, texture->resource.device->surface_alignment,
wined3d_texture_get_level_pow2_width(texture, level),
wined3d_texture_get_level_pow2_height(texture, level),
&src_row_pitch, &src_slice_pitch);
@@ -419,7 +421,7 @@ static void texture2d_download_data(struct wined3d_texture *texture, unsigned in
ERR("Unexpected compressed format for NP2 emulated texture.\n");
}
- if (format->download)
+ if (format_gl->f.download)
{
struct wined3d_format f;
@@ -427,10 +429,10 @@ static void texture2d_download_data(struct wined3d_texture *texture, unsigned in
ERR("Converted texture %p uses PBO unexpectedly.\n", texture);
WARN_(d3d_perf)("Downloading converted texture %p, %u with format %s.\n",
- texture, sub_resource_idx, debug_d3dformat(format->id));
+ texture, sub_resource_idx, debug_d3dformat(format_gl->f.id));
- f = *format;
- f.byte_count = format->conv_byte_count;
+ f = format_gl->f;
+ f.byte_count = format_gl->f.conv_byte_count;
wined3d_texture_get_pitch(texture, level, &dst_row_pitch, &dst_slice_pitch);
wined3d_format_calculate_pitch(&f, texture->resource.device->surface_alignment,
wined3d_texture_get_level_width(texture, level),
@@ -462,7 +464,7 @@ static void texture2d_download_data(struct wined3d_texture *texture, unsigned in
if (texture->resource.format_flags & WINED3DFMT_FLAG_COMPRESSED)
{
TRACE("Downloading compressed texture %p, %u, level %u, format %#x, type %#x, data %p.\n",
- texture, sub_resource_idx, level, format->glFormat, format->glType, mem);
+ texture, sub_resource_idx, level, format_gl->format, format_gl->type, mem);
GL_EXTCALL(glGetCompressedTexImage(target, level, mem));
checkGLcall("glGetCompressedTexImage");
@@ -470,15 +472,15 @@ static void texture2d_download_data(struct wined3d_texture *texture, unsigned in
else
{
TRACE("Downloading texture %p, %u, level %u, format %#x, type %#x, data %p.\n",
- texture, sub_resource_idx, level, format->glFormat, format->glType, mem);
+ texture, sub_resource_idx, level, format_gl->format, format_gl->type, mem);
- gl_info->gl_ops.gl.p_glGetTexImage(target, level, format->glFormat, format->glType, mem);
+ gl_info->gl_ops.gl.p_glGetTexImage(target, level, format_gl->format, format_gl->type, mem);
checkGLcall("glGetTexImage");
}
- if (format->download)
+ if (format_gl->f.download)
{
- format->download(mem, data.addr, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch,
+ format_gl->f.download(mem, data.addr, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch,
wined3d_texture_get_level_width(texture, level),
wined3d_texture_get_level_height(texture, level), 1);
}
@@ -931,7 +933,9 @@ static struct wined3d_texture *surface_convert_format(struct wined3d_texture *sr
static void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, DWORD src_location, DWORD dst_location)
{
- struct wined3d_device *device = texture->resource.device;
+ struct wined3d_resource *resource = &texture->resource;
+ struct wined3d_device *device = resource->device;
+ const struct wined3d_format_gl *format_gl;
struct wined3d_texture *restore_texture;
const struct wined3d_gl_info *gl_info;
unsigned int row_pitch, slice_pitch;
@@ -953,10 +957,10 @@ static void texture2d_read_from_framebuffer(struct wined3d_texture *texture, uns
restore_texture = NULL;
gl_info = context->gl_info;
- if (src_location != texture->resource.draw_binding)
+ if (src_location != resource->draw_binding)
{
context_apply_fbo_state_blit(context, GL_READ_FRAMEBUFFER,
- &texture->resource, sub_resource_idx, NULL, 0, src_location);
+ resource, sub_resource_idx, NULL, 0, src_location);
context_check_fbo_status(context, GL_READ_FRAMEBUFFER);
context_invalidate_state(context, STATE_FRAMEBUFFER);
}
@@ -969,7 +973,7 @@ static void texture2d_read_from_framebuffer(struct wined3d_texture *texture, uns
* There is no need to keep track of the current read buffer or reset it,
* every part of the code that reads sets the read buffer as desired.
*/
- if (src_location != WINED3D_LOCATION_DRAWABLE || wined3d_resource_is_offscreen(&texture->resource))
+ if (src_location != WINED3D_LOCATION_DRAWABLE || wined3d_resource_is_offscreen(resource))
{
/* Mapping the primary render target which is not on a swapchain.
* Read from the back buffer. */
@@ -995,16 +999,16 @@ static void texture2d_read_from_framebuffer(struct wined3d_texture *texture, uns
level = sub_resource_idx % texture->level_count;
wined3d_texture_get_pitch(texture, level, &row_pitch, &slice_pitch);
+ format_gl = wined3d_format_gl(resource->format);
/* Setup pixel store pack state -- to glReadPixels into the correct place */
- gl_info->gl_ops.gl.p_glPixelStorei(GL_PACK_ROW_LENGTH, row_pitch / texture->resource.format->byte_count);
+ gl_info->gl_ops.gl.p_glPixelStorei(GL_PACK_ROW_LENGTH, row_pitch / format_gl->f.byte_count);
checkGLcall("glPixelStorei");
width = wined3d_texture_get_level_width(texture, level);
height = wined3d_texture_get_level_height(texture, level);
gl_info->gl_ops.gl.p_glReadPixels(0, 0, width, height,
- texture->resource.format->glFormat,
- texture->resource.format->glType, data.addr);
+ format_gl->format, format_gl->type, data.addr);
checkGLcall("glReadPixels");
/* Reset previous pixel store pack state */
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index b878e38961e..fdf26512b91 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -561,7 +561,7 @@ static unsigned int wined3d_texture_get_gl_sample_count(const struct wined3d_tex
/* Context activation is done by the caller. */
/* The caller is responsible for binding the correct texture. */
static void wined3d_texture_allocate_gl_mutable_storage(struct wined3d_texture *texture,
- GLenum gl_internal_format, const struct wined3d_format *format,
+ GLenum gl_internal_format, const struct wined3d_format_gl *format,
const struct wined3d_gl_info *gl_info)
{
unsigned int level, level_count, layer, layer_count;
@@ -584,8 +584,8 @@ static void wined3d_texture_allocate_gl_mutable_storage(struct wined3d_texture *
height = wined3d_texture_get_level_pow2_height(texture, level);
if (texture->resource.format_flags & WINED3DFMT_FLAG_HEIGHT_SCALE)
{
- height *= format->height_scale.numerator;
- height /= format->height_scale.denominator;
+ height *= format->f.height_scale.numerator;
+ height /= format->f.height_scale.denominator;
}
TRACE("texture %p, layer %u, level %u, target %#x, width %u, height %u.\n",
@@ -596,19 +596,19 @@ static void wined3d_texture_allocate_gl_mutable_storage(struct wined3d_texture *
depth = wined3d_texture_get_level_depth(texture, level);
GL_EXTCALL(glTexImage3D(target, level, gl_internal_format, width, height,
target == GL_TEXTURE_2D_ARRAY ? texture->layer_count : depth, 0,
- format->glFormat, format->glType, NULL));
+ format->format, format->type, NULL));
checkGLcall("glTexImage3D");
}
else if (target == GL_TEXTURE_1D)
{
gl_info->gl_ops.gl.p_glTexImage1D(target, level, gl_internal_format,
- width, 0, format->glFormat, format->glType, NULL);
+ width, 0, format->format, format->type, NULL);
}
else
{
gl_info->gl_ops.gl.p_glTexImage2D(target, level, gl_internal_format, width,
target == GL_TEXTURE_1D_ARRAY ? texture->layer_count : height, 0,
- format->glFormat, format->glType, NULL);
+ format->format, format->type, NULL);
checkGLcall("glTexImage2D");
}
}
@@ -1513,10 +1513,12 @@ void wined3d_texture_set_compatible_renderbuffer(struct wined3d_texture *texture
if (!renderbuffer)
{
+ const struct wined3d_format_gl *format_gl;
+
+ format_gl = wined3d_format_gl(texture->resource.format);
gl_info->fbo_ops.glGenRenderbuffers(1, &renderbuffer);
gl_info->fbo_ops.glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
- gl_info->fbo_ops.glRenderbufferStorage(GL_RENDERBUFFER,
- texture->resource.format->glInternal, width, height);
+ gl_info->fbo_ops.glRenderbufferStorage(GL_RENDERBUFFER, format_gl->internal, width, height);
entry = heap_alloc(sizeof(*entry));
entry->width = width;
@@ -1712,11 +1714,13 @@ static void wined3d_texture_force_reload(struct wined3d_texture *texture)
void wined3d_texture_prepare_texture(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
{
DWORD alloc_flag = srgb ? WINED3D_TEXTURE_SRGB_ALLOCATED : WINED3D_TEXTURE_RGB_ALLOCATED;
- const struct wined3d_device *device = texture->resource.device;
- const struct wined3d_format *format = texture->resource.format;
const struct wined3d_d3d_info *d3d_info = context->d3d_info;
const struct wined3d_gl_info *gl_info = context->gl_info;
+ struct wined3d_resource *resource = &texture->resource;
+ const struct wined3d_device *device = resource->device;
+ const struct wined3d_format *format = resource->format;
const struct wined3d_color_key_conversion *conversion;
+ const struct wined3d_format_gl *format_gl;
GLenum internal;
TRACE("texture %p, context %p, format %s.\n", texture, context, debug_d3dformat(format->id));
@@ -1734,11 +1738,11 @@ void wined3d_texture_prepare_texture(struct wined3d_texture *texture, struct win
if (texture->flags & alloc_flag)
return;
- if (texture->resource.format_flags & WINED3DFMT_FLAG_DECOMPRESS)
+ if (resource->format_flags & WINED3DFMT_FLAG_DECOMPRESS)
{
TRACE("WINED3DFMT_FLAG_DECOMPRESS set.\n");
texture->flags |= WINED3D_TEXTURE_CONVERTED;
- format = wined3d_resource_get_decompress_format(&texture->resource);
+ format = wined3d_resource_get_decompress_format(resource);
}
else if (format->conv_byte_count)
{
@@ -1747,37 +1751,38 @@ void wined3d_texture_prepare_texture(struct wined3d_texture *texture, struct win
else if ((conversion = wined3d_format_get_color_key_conversion(texture, TRUE)))
{
texture->flags |= WINED3D_TEXTURE_CONVERTED;
- format = wined3d_get_format(device->adapter, conversion->dst_format, texture->resource.usage);
+ format = wined3d_get_format(device->adapter, conversion->dst_format, resource->usage);
TRACE("Using format %s for color key conversion.\n", debug_d3dformat(format->id));
}
+ format_gl = wined3d_format_gl(format);
wined3d_texture_bind_and_dirtify(texture, context, srgb);
if (srgb)
- internal = format->glGammaInternal;
- else if (texture->resource.usage & WINED3DUSAGE_RENDERTARGET
- && wined3d_resource_is_offscreen(&texture->resource))
- internal = format->rtInternal;
+ internal = format_gl->srgb_internal;
+ else if (resource->usage & WINED3DUSAGE_RENDERTARGET && wined3d_resource_is_offscreen(resource))
+ internal = format_gl->rt_internal;
else
- internal = format->glInternal;
+ internal = format_gl->internal;
if (!internal)
FIXME("No GL internal format for format %s.\n", debug_d3dformat(format->id));
- TRACE("internal %#x, format %#x, type %#x.\n", internal, format->glFormat, format->glType);
+ TRACE("internal %#x, format %#x, type %#x.\n", internal, format_gl->format, format_gl->type);
if (wined3d_texture_use_immutable_storage(texture, gl_info))
wined3d_texture_allocate_gl_immutable_storage(texture, internal, gl_info);
else
- wined3d_texture_allocate_gl_mutable_storage(texture, internal, format, gl_info);
+ wined3d_texture_allocate_gl_mutable_storage(texture, internal, format_gl, gl_info);
texture->flags |= alloc_flag;
}
static void wined3d_texture_prepare_rb(struct wined3d_texture *texture,
const struct wined3d_gl_info *gl_info, BOOL multisample)
{
- const struct wined3d_format *format = texture->resource.format;
+ const struct wined3d_format_gl *format_gl;
+ format_gl = wined3d_format_gl(texture->resource.format);
if (multisample)
{
DWORD samples;
@@ -1790,7 +1795,7 @@ static void wined3d_texture_prepare_rb(struct wined3d_texture *texture,
gl_info->fbo_ops.glGenRenderbuffers(1, &texture->rb_multisample);
gl_info->fbo_ops.glBindRenderbuffer(GL_RENDERBUFFER, texture->rb_multisample);
gl_info->fbo_ops.glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples,
- format->glInternal, texture->resource.width, texture->resource.height);
+ format_gl->internal, texture->resource.width, texture->resource.height);
checkGLcall("glRenderbufferStorageMultisample()");
TRACE("Created multisample rb %u.\n", texture->rb_multisample);
}
@@ -1801,7 +1806,7 @@ static void wined3d_texture_prepare_rb(struct wined3d_texture *texture,
gl_info->fbo_ops.glGenRenderbuffers(1, &texture->rb_resolved);
gl_info->fbo_ops.glBindRenderbuffer(GL_RENDERBUFFER, texture->rb_resolved);
- gl_info->fbo_ops.glRenderbufferStorage(GL_RENDERBUFFER, format->glInternal,
+ gl_info->fbo_ops.glRenderbufferStorage(GL_RENDERBUFFER, format_gl->internal,
texture->resource.width, texture->resource.height);
checkGLcall("glRenderbufferStorage()");
TRACE("Created resolved rb %u.\n", texture->rb_resolved);
@@ -1906,9 +1911,10 @@ void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int s
unsigned int update_w = src_box->right - src_box->left;
unsigned int update_h = src_box->bottom - src_box->top;
unsigned int update_d = src_box->back - src_box->front;
+ const struct wined3d_format_gl *format_gl;
struct wined3d_bo_address bo;
void *converted_mem = NULL;
- struct wined3d_format f;
+ struct wined3d_format_gl f;
unsigned int level;
BOOL decompress;
GLenum target;
@@ -1978,9 +1984,9 @@ void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int s
if (texture->resource.format_flags & WINED3DFMT_FLAG_BLOCKS)
ERR("Converting a block-based format.\n");
- f = *format;
- f.byte_count = format->conv_byte_count;
- format = &f;
+ f = *wined3d_format_gl(format);
+ f.f.byte_count = format->conv_byte_count;
+ format = &f.f;
}
wined3d_format_calculate_pitch(format, 1, update_w, update_h, &dst_row_pitch, &dst_slice_pitch);
@@ -2015,6 +2021,7 @@ void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int s
checkGLcall("glBindBuffer");
}
+ format_gl = wined3d_format_gl(format);
if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_COMPRESSED)
{
unsigned int dst_row_pitch, dst_slice_pitch;
@@ -2022,12 +2029,12 @@ void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int s
GLenum internal;
if (srgb)
- internal = format->glGammaInternal;
+ internal = format_gl->srgb_internal;
else if (texture->resource.usage & WINED3DUSAGE_RENDERTARGET
&& wined3d_resource_is_offscreen(&texture->resource))
- internal = format->rtInternal;
+ internal = format_gl->rt_internal;
else
- internal = format->glInternal;
+ internal = format_gl->internal;
wined3d_format_calculate_pitch(format, 1, update_w, update_h, &dst_row_pitch, &dst_slice_pitch);
@@ -2088,23 +2095,23 @@ void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int s
TRACE("Uploading data, target %#x, level %u, x %u, y %u, z %u, "
"w %u, h %u, d %u, format %#x, type %#x, addr %p.\n",
target, level, dst_x, dst_y, dst_z, update_w, update_h,
- update_d, format->glFormat, format->glType, bo.addr);
+ update_d, format_gl->format, format_gl->type, bo.addr);
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, src_row_pitch / format->byte_count);
if (target == GL_TEXTURE_2D_ARRAY || target == GL_TEXTURE_3D)
{
GL_EXTCALL(glTexSubImage3D(target, level, dst_x, dst_y, dst_z,
- update_w, update_h, update_d, format->glFormat, format->glType, bo.addr));
+ update_w, update_h, update_d, format_gl->format, format_gl->type, bo.addr));
}
else if (target == GL_TEXTURE_1D)
{
gl_info->gl_ops.gl.p_glTexSubImage1D(target, level, dst_x,
- update_w, format->glFormat, format->glType, bo.addr);
+ update_w, format_gl->format, format_gl->type, bo.addr);
}
else
{
gl_info->gl_ops.gl.p_glTexSubImage2D(target, level, dst_x, dst_y,
- update_w, update_h, format->glFormat, format->glType, bo.addr);
+ update_w, update_h, format_gl->format, format_gl->type, bo.addr);
}
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
checkGLcall("Upload texture data");
@@ -2437,13 +2444,14 @@ static const struct wined3d_resource_ops texture_resource_ops =
static void texture1d_download_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
const struct wined3d_context *context, const struct wined3d_bo_address *data)
{
- const struct wined3d_format *format = texture->resource.format;
const struct wined3d_gl_info *gl_info = context->gl_info;
+ const struct wined3d_format_gl *format_gl;
- if (format->conv_byte_count)
+ format_gl = wined3d_format_gl(texture->resource.format);
+ if (format_gl->f.conv_byte_count)
{
FIXME("Attempting to download a converted texture, format %s.\n",
- debug_d3dformat(format->id));
+ debug_d3dformat(format_gl->f.id));
return;
}
@@ -2454,7 +2462,7 @@ static void texture1d_download_data(struct wined3d_texture *texture, unsigned in
}
gl_info->gl_ops.gl.p_glGetTexImage(texture->target, sub_resource_idx,
- format->glFormat, format->glType, data->addr);
+ format_gl->format, format_gl->type, data->addr);
checkGLcall("glGetTexImage");
if (data->buffer_object)
@@ -2909,13 +2917,14 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
static void texture3d_download_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
const struct wined3d_context *context, const struct wined3d_bo_address *data)
{
- const struct wined3d_format *format = texture->resource.format;
const struct wined3d_gl_info *gl_info = context->gl_info;
+ const struct wined3d_format_gl *format_gl;
- if (format->conv_byte_count)
+ format_gl = wined3d_format_gl(texture->resource.format);
+ if (format_gl->f.conv_byte_count)
{
FIXME("Attempting to download a converted volume, format %s.\n",
- debug_d3dformat(format->id));
+ debug_d3dformat(format_gl->f.id));
return;
}
@@ -2926,7 +2935,7 @@ static void texture3d_download_data(struct wined3d_texture *texture, unsigned in
}
gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_3D, sub_resource_idx,
- format->glFormat, format->glType, data->addr);
+ format_gl->format, format_gl->type, data->addr);
checkGLcall("glGetTexImage");
if (data->buffer_object)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 36694856081..055d546ccba 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -1935,6 +1935,11 @@ static struct wined3d_format *get_format_by_idx(const struct wined3d_adapter *ad
return (struct wined3d_format *)((BYTE *)adapter->formats + fmt_idx * adapter->format_size);
}
+static struct wined3d_format_gl *get_format_gl_by_idx(const struct wined3d_adapter *adapter, int fmt_idx)
+{
+ return wined3d_format_gl_mutable(get_format_by_idx(adapter, fmt_idx));
+}
+
static struct wined3d_format *get_format_internal(const struct wined3d_adapter *adapter,
enum wined3d_format_id format_id)
{
@@ -2431,7 +2436,7 @@ static void draw_test_quad(struct wined3d_caps_gl_ctx *ctx, const struct wined3d
}
/* Context activation is done by the caller. */
-static void check_fbo_compat(struct wined3d_caps_gl_ctx *ctx, struct wined3d_format *format)
+static void check_fbo_compat(struct wined3d_caps_gl_ctx *ctx, struct wined3d_format_gl *format)
{
/* Check if the default internal format is supported as a frame buffer
* target, otherwise fall back to the render target internal.
@@ -2440,24 +2445,24 @@ static void check_fbo_compat(struct wined3d_caps_gl_ctx *ctx, struct wined3d_for
static const struct wined3d_color black = {0.0f, 0.0f, 0.0f, 1.0f};
static const struct wined3d_color half_transparent_red = {1.0f, 0.0f, 0.0f, 0.5f};
const struct wined3d_gl_info *gl_info = ctx->gl_info;
- GLenum status, rt_internal = format->rtInternal;
+ GLenum status, rt_internal = format->rt_internal;
GLuint object, color_rb;
enum wined3d_gl_resource_type type;
BOOL fallback_fmt_used = FALSE, regular_fmt_used = FALSE;
gl_info->gl_ops.gl.p_glDisable(GL_BLEND);
- for (type = 0; type < ARRAY_SIZE(format->flags); ++type)
+ for (type = 0; type < ARRAY_SIZE(format->f.flags); ++type)
{
const char *type_string = "color";
if (type == WINED3D_GL_RES_TYPE_BUFFER)
continue;
- create_and_bind_fbo_attachment(gl_info, format->flags[type], type, &object, format->glInternal,
- format->glFormat, format->glType);
+ create_and_bind_fbo_attachment(gl_info, format->f.flags[type], type,
+ &object, format->internal, format->format, format->type);
- if (format->flags[type] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
+ if (format->f.flags[type] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
{
gl_info->fbo_ops.glGenRenderbuffers(1, &color_rb);
gl_info->fbo_ops.glBindRenderbuffer(GL_RENDERBUFFER, color_rb);
@@ -2478,39 +2483,39 @@ static void check_fbo_compat(struct wined3d_caps_gl_ctx *ctx, struct wined3d_for
if (status == GL_FRAMEBUFFER_COMPLETE)
{
TRACE("Format %s is supported as FBO %s attachment, type %u.\n",
- debug_d3dformat(format->id), type_string, type);
- format->flags[type] |= WINED3DFMT_FLAG_FBO_ATTACHABLE;
- format->rtInternal = format->glInternal;
+ debug_d3dformat(format->f.id), type_string, type);
+ format->f.flags[type] |= WINED3DFMT_FLAG_FBO_ATTACHABLE;
+ format->rt_internal = format->internal;
regular_fmt_used = TRUE;
}
else
{
if (!rt_internal)
{
- if (format->flags[type] & WINED3DFMT_FLAG_RENDERTARGET)
+ if (format->f.flags[type] & WINED3DFMT_FLAG_RENDERTARGET)
{
WARN("Format %s with rendertarget flag is not supported as FBO color attachment (type %u),"
- " and no fallback specified.\n", debug_d3dformat(format->id), type);
- format->flags[type] &= ~WINED3DFMT_FLAG_RENDERTARGET;
+ " and no fallback specified.\n", debug_d3dformat(format->f.id), type);
+ format->f.flags[type] &= ~WINED3DFMT_FLAG_RENDERTARGET;
}
else
{
TRACE("Format %s is not supported as FBO %s attachment, type %u.\n",
- debug_d3dformat(format->id), type_string, type);
+ debug_d3dformat(format->f.id), type_string, type);
}
- format->rtInternal = format->glInternal;
+ format->rt_internal = format->internal;
}
else
{
TRACE("Format %s is not supported as FBO %s attachment (type %u),"
" trying rtInternal format as fallback.\n",
- debug_d3dformat(format->id), type_string, type);
+ debug_d3dformat(format->f.id), type_string, type);
while (gl_info->gl_ops.gl.p_glGetError());
delete_fbo_attachment(gl_info, type, object);
- create_and_bind_fbo_attachment(gl_info, format->flags[type], type, &object, format->rtInternal,
- format->glFormat, format->glType);
+ create_and_bind_fbo_attachment(gl_info, format->f.flags[type], type,
+ &object, format->rt_internal, format->format, format->type);
status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
checkGLcall("Framebuffer format check");
@@ -2518,25 +2523,25 @@ static void check_fbo_compat(struct wined3d_caps_gl_ctx *ctx, struct wined3d_for
if (status == GL_FRAMEBUFFER_COMPLETE)
{
TRACE("Format %s rtInternal format is supported as FBO %s attachment, type %u.\n",
- debug_d3dformat(format->id), type_string, type);
+ debug_d3dformat(format->f.id), type_string, type);
fallback_fmt_used = TRUE;
}
else
{
WARN("Format %s rtInternal format is not supported as FBO %s attachment, type %u.\n",
- debug_d3dformat(format->id), type_string, type);
- format->flags[type] &= ~WINED3DFMT_FLAG_RENDERTARGET;
+ debug_d3dformat(format->f.id), type_string, type);
+ format->f.flags[type] &= ~WINED3DFMT_FLAG_RENDERTARGET;
}
}
}
if (status == GL_FRAMEBUFFER_COMPLETE
- && ((format->flags[type] & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING)
+ && ((format->f.flags[type] & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING)
|| !(gl_info->quirks & WINED3D_QUIRK_LIMITED_TEX_FILTERING))
- && !(format->flags[type] & WINED3DFMT_FLAG_INTEGER)
- && format->id != WINED3DFMT_NULL && format->id != WINED3DFMT_P8_UINT
- && format->glFormat != GL_LUMINANCE && format->glFormat != GL_LUMINANCE_ALPHA
- && (format->red_size || format->alpha_size))
+ && !(format->f.flags[type] & WINED3DFMT_FLAG_INTEGER)
+ && format->f.id != WINED3DFMT_NULL && format->f.id != WINED3DFMT_P8_UINT
+ && format->format != GL_LUMINANCE && format->format != GL_LUMINANCE_ALPHA
+ && (format->f.red_size || format->f.alpha_size))
{
DWORD readback[16 * 16 * 16], color, r_range, a_range;
BYTE r, a;
@@ -2564,8 +2569,8 @@ static void check_fbo_compat(struct wined3d_caps_gl_ctx *ctx, struct wined3d_for
{
while (gl_info->gl_ops.gl.p_glGetError());
TRACE("Format %s doesn't support post-pixelshader blending, type %u.\n",
- debug_d3dformat(format->id), type);
- format->flags[type] &= ~WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
+ debug_d3dformat(format->f.id), type);
+ format->f.flags[type] &= ~WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
}
else
{
@@ -2628,25 +2633,25 @@ static void check_fbo_compat(struct wined3d_caps_gl_ctx *ctx, struct wined3d_for
a = color >> 24;
r = (color & 0x00ff0000u) >> 16;
- r_range = format->red_size < 8 ? 1u << (8 - format->red_size) : 1;
- a_range = format->alpha_size < 8 ? 1u << (8 - format->alpha_size) : 1;
- if (format->red_size && (r < 0x7f - r_range || r > 0x7f + r_range))
+ r_range = format->f.red_size < 8 ? 1u << (8 - format->f.red_size) : 1;
+ a_range = format->f.alpha_size < 8 ? 1u << (8 - format->f.alpha_size) : 1;
+ if (format->f.red_size && (r < 0x7f - r_range || r > 0x7f + r_range))
match = FALSE;
- else if (format->alpha_size > 1 && (a < 0xbf - a_range || a > 0xbf + a_range))
+ else if (format->f.alpha_size > 1 && (a < 0xbf - a_range || a > 0xbf + a_range))
match = FALSE;
if (!match)
{
TRACE("Format %s doesn't support post-pixelshader blending, type %u.\n",
- debug_d3dformat(format->id), type);
+ debug_d3dformat(format->f.id), type);
TRACE("Color output: %#x\n", color);
- format->flags[type] &= ~WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
+ format->f.flags[type] &= ~WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
}
else
{
TRACE("Format %s supports post-pixelshader blending, type %u.\n",
- debug_d3dformat(format->id), type);
+ debug_d3dformat(format->f.id), type);
TRACE("Color output: %#x\n", color);
- format->flags[type] |= WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
+ format->f.flags[type] |= WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
}
}
@@ -2660,11 +2665,11 @@ static void check_fbo_compat(struct wined3d_caps_gl_ctx *ctx, struct wined3d_for
}
}
- if (format->glInternal != format->glGammaInternal)
+ if (format->internal != format->srgb_internal)
{
delete_fbo_attachment(gl_info, type, object);
- create_and_bind_fbo_attachment(gl_info, format->flags[type], type, &object, format->glGammaInternal,
- format->glFormat, format->glType);
+ create_and_bind_fbo_attachment(gl_info, format->f.flags[type], type, &object, format->srgb_internal,
+ format->format, format->type);
status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
checkGLcall("Framebuffer format check");
@@ -2672,22 +2677,22 @@ static void check_fbo_compat(struct wined3d_caps_gl_ctx *ctx, struct wined3d_for
if (status == GL_FRAMEBUFFER_COMPLETE)
{
TRACE("Format %s's sRGB format is FBO attachable, type %u.\n",
- debug_d3dformat(format->id), type);
- format->flags[type] |= WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB;
+ debug_d3dformat(format->f.id), type);
+ format->f.flags[type] |= WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB;
if (gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
- format->glInternal = format->glGammaInternal;
+ format->internal = format->srgb_internal;
}
else
{
WARN("Format %s's sRGB format is not FBO attachable, type %u.\n",
- debug_d3dformat(format->id), type);
- format_clear_flag(format, WINED3DFMT_FLAG_SRGB_WRITE);
+ debug_d3dformat(format->f.id), type);
+ format_clear_flag(&format->f, WINED3DFMT_FLAG_SRGB_WRITE);
}
}
else if (status == GL_FRAMEBUFFER_COMPLETE)
- format->flags[type] |= WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB;
+ format->f.flags[type] |= WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB;
- if (format->flags[type] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
+ if (format->f.flags[type] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
{
gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
gl_info->fbo_ops.glDeleteRenderbuffers(1, &color_rb);
@@ -2700,30 +2705,30 @@ static void check_fbo_compat(struct wined3d_caps_gl_ctx *ctx, struct wined3d_for
if (fallback_fmt_used && regular_fmt_used)
{
FIXME("Format %s needs different render target formats for different resource types.\n",
- debug_d3dformat(format->id));
- format_clear_flag(format, WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FBO_ATTACHABLE
+ debug_d3dformat(format->f.id));
+ format_clear_flag(&format->f, WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FBO_ATTACHABLE
| WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING);
}
}
-static void query_format_flag(struct wined3d_gl_info *gl_info, struct wined3d_format *format,
+static void query_format_flag(struct wined3d_gl_info *gl_info, struct wined3d_format_gl *format,
GLint internal, GLenum pname, DWORD flag, const char *string)
{
GLint value;
enum wined3d_gl_resource_type type;
- for (type = 0; type < ARRAY_SIZE(format->flags); ++type)
+ for (type = 0; type < ARRAY_SIZE(format->f.flags); ++type)
{
gl_info->gl_ops.ext.p_glGetInternalformativ(wined3d_gl_type_to_enum(type), internal, pname, 1, &value);
if (value == GL_FULL_SUPPORT)
{
- TRACE("Format %s supports %s, resource type %u.\n", debug_d3dformat(format->id), string, type);
- format->flags[type] |= flag;
+ TRACE("Format %s supports %s, resource type %u.\n", debug_d3dformat(format->f.id), string, type);
+ format->f.flags[type] |= flag;
}
else
{
- TRACE("Format %s doesn't support %s, resource type %u.\n", debug_d3dformat(format->id), string, type);
- format->flags[type] &= ~flag;
+ TRACE("Format %s doesn't support %s, resource type %u.\n", debug_d3dformat(format->f.id), string, type);
+ format->f.flags[type] &= ~flag;
}
}
}
@@ -2740,56 +2745,56 @@ static void init_format_fbo_compat_info(const struct wined3d_adapter *adapter,
{
for (i = 0; i < WINED3D_FORMAT_COUNT; ++i)
{
- struct wined3d_format *format = get_format_by_idx(adapter, i);
+ struct wined3d_format_gl *format = get_format_gl_by_idx(adapter, i);
BOOL fallback_fmt_used = FALSE, regular_fmt_used = FALSE;
- GLenum rt_internal = format->rtInternal;
+ GLenum rt_internal = format->rt_internal;
GLint value;
- if (!format->glInternal)
+ if (!format->internal)
continue;
- for (type = 0; type < ARRAY_SIZE(format->flags); ++type)
+ for (type = 0; type < ARRAY_SIZE(format->f.flags); ++type)
{
gl_info->gl_ops.ext.p_glGetInternalformativ(wined3d_gl_type_to_enum(type),
- format->glInternal, GL_FRAMEBUFFER_RENDERABLE, 1, &value);
+ format->internal, GL_FRAMEBUFFER_RENDERABLE, 1, &value);
if (value == GL_FULL_SUPPORT)
{
TRACE("Format %s is supported as FBO color attachment, resource type %u.\n",
- debug_d3dformat(format->id), type);
- format->flags[type] |= WINED3DFMT_FLAG_FBO_ATTACHABLE;
- format->rtInternal = format->glInternal;
+ debug_d3dformat(format->f.id), type);
+ format->f.flags[type] |= WINED3DFMT_FLAG_FBO_ATTACHABLE;
+ format->rt_internal = format->internal;
regular_fmt_used = TRUE;
gl_info->gl_ops.ext.p_glGetInternalformativ(wined3d_gl_type_to_enum(type),
- format->glInternal, GL_FRAMEBUFFER_BLEND, 1, &value);
+ format->internal, GL_FRAMEBUFFER_BLEND, 1, &value);
if (value == GL_FULL_SUPPORT)
{
TRACE("Format %s supports post-pixelshader blending, resource type %u.\n",
- debug_d3dformat(format->id), type);
- format->flags[type] |= WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
+ debug_d3dformat(format->f.id), type);
+ format->f.flags[type] |= WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
}
else
{
TRACE("Format %s doesn't support post-pixelshader blending, resource typed %u.\n",
- debug_d3dformat(format->id), type);
- format->flags[type] &= ~WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
+ debug_d3dformat(format->f.id), type);
+ format->f.flags[type] &= ~WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
}
}
else
{
if (!rt_internal)
{
- if (format->flags[type] & WINED3DFMT_FLAG_RENDERTARGET)
+ if (format->f.flags[type] & WINED3DFMT_FLAG_RENDERTARGET)
{
WARN("Format %s with rendertarget flag is not supported as FBO color attachment"
" and no fallback specified, resource type %u.\n",
- debug_d3dformat(format->id), type);
- format->flags[type] &= ~WINED3DFMT_FLAG_RENDERTARGET;
+ debug_d3dformat(format->f.id), type);
+ format->f.flags[type] &= ~WINED3DFMT_FLAG_RENDERTARGET;
}
else
TRACE("Format %s is not supported as FBO color attachment,"
- " resource type %u.\n", debug_d3dformat(format->id), type);
- format->rtInternal = format->glInternal;
+ " resource type %u.\n", debug_d3dformat(format->f.id), type);
+ format->rt_internal = format->internal;
}
else
{
@@ -2798,46 +2803,46 @@ static void init_format_fbo_compat_info(const struct wined3d_adapter *adapter,
if (value == GL_FULL_SUPPORT)
{
TRACE("Format %s rtInternal format is supported as FBO color attachment,"
- " resource type %u.\n", debug_d3dformat(format->id), type);
+ " resource type %u.\n", debug_d3dformat(format->f.id), type);
fallback_fmt_used = TRUE;
}
else
{
WARN("Format %s rtInternal format is not supported as FBO color attachment,"
- " resource type %u.\n", debug_d3dformat(format->id), type);
- format->flags[type] &= ~WINED3DFMT_FLAG_RENDERTARGET;
+ " resource type %u.\n", debug_d3dformat(format->f.id), type);
+ format->f.flags[type] &= ~WINED3DFMT_FLAG_RENDERTARGET;
}
}
}
- if (format->glInternal != format->glGammaInternal)
+ if (format->internal != format->srgb_internal)
{
gl_info->gl_ops.ext.p_glGetInternalformativ(wined3d_gl_type_to_enum(type),
- format->glGammaInternal, GL_FRAMEBUFFER_RENDERABLE, 1, &value);
+ format->srgb_internal, GL_FRAMEBUFFER_RENDERABLE, 1, &value);
if (value == GL_FULL_SUPPORT)
{
TRACE("Format %s's sRGB format is FBO attachable, resource type %u.\n",
- debug_d3dformat(format->id), type);
- format->flags[type] |= WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB;
+ debug_d3dformat(format->f.id), type);
+ format->f.flags[type] |= WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB;
if (gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
- format->glInternal = format->glGammaInternal;
+ format->internal = format->srgb_internal;
}
else
{
WARN("Format %s's sRGB format is not FBO attachable, resource type %u.\n",
- debug_d3dformat(format->id), type);
- format_clear_flag(format, WINED3DFMT_FLAG_SRGB_WRITE);
+ debug_d3dformat(format->f.id), type);
+ format_clear_flag(&format->f, WINED3DFMT_FLAG_SRGB_WRITE);
}
}
- else if (format->flags[type] & WINED3DFMT_FLAG_FBO_ATTACHABLE)
- format->flags[type] |= WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB;
+ else if (format->f.flags[type] & WINED3DFMT_FLAG_FBO_ATTACHABLE)
+ format->f.flags[type] |= WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB;
}
if (fallback_fmt_used && regular_fmt_used)
{
FIXME("Format %s needs different render target formats for different resource types.\n",
- debug_d3dformat(format->id));
- format_clear_flag(format, WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FBO_ATTACHABLE
+ debug_d3dformat(format->f.id));
+ format_clear_flag(&format->f, WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FBO_ATTACHABLE
| WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING);
}
}
@@ -2854,25 +2859,26 @@ static void init_format_fbo_compat_info(const struct wined3d_adapter *adapter,
for (i = 0; i < WINED3D_FORMAT_COUNT; ++i)
{
- struct wined3d_format *format = get_format_by_idx(adapter, i);
+ struct wined3d_format_gl *format = get_format_gl_by_idx(adapter, i);
- if (!format->glInternal) continue;
+ if (!format->internal)
+ continue;
- if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_COMPRESSED)
+ if (format->f.flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_COMPRESSED)
{
TRACE("Skipping format %s because it's a compressed format.\n",
- debug_d3dformat(format->id));
+ debug_d3dformat(format->f.id));
continue;
}
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
- TRACE("Checking if format %s is supported as FBO color attachment...\n", debug_d3dformat(format->id));
+ TRACE("Checking if format %s is supported as FBO color attachment...\n", debug_d3dformat(format->f.id));
check_fbo_compat(ctx, format);
}
else
{
- format->rtInternal = format->glInternal;
+ format->rt_internal = format->internal;
}
}
@@ -2995,9 +3001,9 @@ static void query_view_class(struct wined3d_format_gl *format)
{
GLenum internal_view_class, gamma_view_class, rt_view_class;
- internal_view_class = lookup_gl_view_class(format->f.glInternal);
- gamma_view_class = lookup_gl_view_class(format->f.glGammaInternal);
- rt_view_class = lookup_gl_view_class(format->f.rtInternal);
+ internal_view_class = lookup_gl_view_class(format->internal);
+ gamma_view_class = lookup_gl_view_class(format->srgb_internal);
+ rt_view_class = lookup_gl_view_class(format->rt_internal);
if (internal_view_class == gamma_view_class || gamma_view_class == rt_view_class)
{
@@ -3012,7 +3018,7 @@ static void query_view_class(struct wined3d_format_gl *format)
}
static void query_internal_format(struct wined3d_adapter *adapter,
- struct wined3d_format *format, const struct wined3d_format_texture_info *texture_info,
+ struct wined3d_format_gl *format, const struct wined3d_format_texture_info *texture_info,
struct wined3d_gl_info *gl_info, BOOL srgb_write_supported, BOOL srgb_format)
{
GLint count, multisample_types[8];
@@ -3021,105 +3027,106 @@ static void query_internal_format(struct wined3d_adapter *adapter,
if (gl_info->supported[ARB_INTERNALFORMAT_QUERY2])
{
- query_format_flag(gl_info, format, format->glInternal, GL_VERTEX_TEXTURE,
+ query_format_flag(gl_info, format, format->internal, GL_VERTEX_TEXTURE,
WINED3DFMT_FLAG_VTF, "vertex texture usage");
- query_format_flag(gl_info, format, format->glInternal, GL_FILTER,
+ query_format_flag(gl_info, format, format->internal, GL_FILTER,
WINED3DFMT_FLAG_FILTERING, "filtering");
- if (srgb_format || format->glGammaInternal != format->glInternal)
+ if (srgb_format || format->srgb_internal != format->internal)
{
- query_format_flag(gl_info, format, format->glGammaInternal, GL_SRGB_READ,
+ query_format_flag(gl_info, format, format->srgb_internal, GL_SRGB_READ,
WINED3DFMT_FLAG_SRGB_READ, "sRGB read");
if (srgb_write_supported)
- query_format_flag(gl_info, format, format->glGammaInternal, GL_SRGB_WRITE,
+ query_format_flag(gl_info, format, format->srgb_internal, GL_SRGB_WRITE,
WINED3DFMT_FLAG_SRGB_WRITE, "sRGB write");
else
- format_clear_flag(format, WINED3DFMT_FLAG_SRGB_WRITE);
+ format_clear_flag(&format->f, WINED3DFMT_FLAG_SRGB_WRITE);
- if (!(format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & (WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE)))
- format->glGammaInternal = format->glInternal;
+ if (!(format->f.flags[WINED3D_GL_RES_TYPE_TEX_2D]
+ & (WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE)))
+ format->srgb_internal = format->internal;
else if (wined3d_settings.offscreen_rendering_mode != ORM_FBO
&& gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
- format->glInternal = format->glGammaInternal;
+ format->internal = format->srgb_internal;
}
}
else
{
if (!gl_info->limits.samplers[WINED3D_SHADER_TYPE_VERTEX])
- format_clear_flag(format, WINED3DFMT_FLAG_VTF);
+ format_clear_flag(&format->f, WINED3DFMT_FLAG_VTF);
if (!(gl_info->quirks & WINED3D_QUIRK_LIMITED_TEX_FILTERING))
- format_set_flag(format, WINED3DFMT_FLAG_FILTERING);
- else if (format->id != WINED3DFMT_R32G32B32A32_FLOAT && format->id != WINED3DFMT_R32_FLOAT)
- format_clear_flag(format, WINED3DFMT_FLAG_VTF);
+ format_set_flag(&format->f, WINED3DFMT_FLAG_FILTERING);
+ else if (format->f.id != WINED3DFMT_R32G32B32A32_FLOAT && format->f.id != WINED3DFMT_R32_FLOAT)
+ format_clear_flag(&format->f, WINED3DFMT_FLAG_VTF);
- if (srgb_format || format->glGammaInternal != format->glInternal)
+ if (srgb_format || format->srgb_internal != format->internal)
{
/* Filter sRGB capabilities if EXT_texture_sRGB is not supported. */
if (!gl_info->supported[EXT_TEXTURE_SRGB])
{
- format->glGammaInternal = format->glInternal;
- format_clear_flag(format, WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE);
+ format->srgb_internal = format->internal;
+ format_clear_flag(&format->f, WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE);
}
else if (wined3d_settings.offscreen_rendering_mode != ORM_FBO
&& gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
{
- format->glInternal = format->glGammaInternal;
+ format->internal = format->srgb_internal;
}
}
- if ((format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_SRGB_WRITE) && !srgb_write_supported)
- format_clear_flag(format, WINED3DFMT_FLAG_SRGB_WRITE);
+ if ((format->f.flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_SRGB_WRITE) && !srgb_write_supported)
+ format_clear_flag(&format->f, WINED3DFMT_FLAG_SRGB_WRITE);
if (!gl_info->supported[ARB_DEPTH_TEXTURE]
&& texture_info->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
{
- format->flags[WINED3D_GL_RES_TYPE_TEX_1D] &= ~WINED3DFMT_FLAG_TEXTURE;
- format->flags[WINED3D_GL_RES_TYPE_TEX_2D] &= ~WINED3DFMT_FLAG_TEXTURE;
- format->flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
- format->flags[WINED3D_GL_RES_TYPE_TEX_CUBE] &= ~WINED3DFMT_FLAG_TEXTURE;
- format->flags[WINED3D_GL_RES_TYPE_TEX_RECT] &= ~WINED3DFMT_FLAG_TEXTURE;
+ format->f.flags[WINED3D_GL_RES_TYPE_TEX_1D] &= ~WINED3DFMT_FLAG_TEXTURE;
+ format->f.flags[WINED3D_GL_RES_TYPE_TEX_2D] &= ~WINED3DFMT_FLAG_TEXTURE;
+ format->f.flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
+ format->f.flags[WINED3D_GL_RES_TYPE_TEX_CUBE] &= ~WINED3DFMT_FLAG_TEXTURE;
+ format->f.flags[WINED3D_GL_RES_TYPE_TEX_RECT] &= ~WINED3DFMT_FLAG_TEXTURE;
}
}
- query_view_class(wined3d_format_gl_mutable(format));
+ query_view_class(format);
- if (format->glInternal && format->flags[WINED3D_GL_RES_TYPE_RB]
+ if (format->internal && format->f.flags[WINED3D_GL_RES_TYPE_RB]
& (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
{
if (gl_info->supported[ARB_INTERNALFORMAT_QUERY])
{
target = gl_info->supported[ARB_TEXTURE_MULTISAMPLE] ? GL_TEXTURE_2D_MULTISAMPLE : GL_RENDERBUFFER;
count = 0;
- GL_EXTCALL(glGetInternalformativ(target, format->glInternal,
+ GL_EXTCALL(glGetInternalformativ(target, format->internal,
GL_NUM_SAMPLE_COUNTS, 1, &count));
if (count > ARRAY_SIZE(multisample_types))
FIXME("Unexpectedly high number of multisample types %d.\n", count);
count = min(count, ARRAY_SIZE(multisample_types));
- GL_EXTCALL(glGetInternalformativ(target, format->glInternal,
+ GL_EXTCALL(glGetInternalformativ(target, format->internal,
GL_SAMPLES, count, multisample_types));
checkGLcall("query sample counts");
for (i = 0; i < count; ++i)
{
- if (multisample_types[i] > sizeof(format->multisample_types) * CHAR_BIT)
+ if (multisample_types[i] > sizeof(format->f.multisample_types) * CHAR_BIT)
continue;
- format->multisample_types |= 1u << (multisample_types[i] - 1);
+ format->f.multisample_types |= 1u << (multisample_types[i] - 1);
}
}
else
{
max_log2 = wined3d_log2i(min(gl_info->limits.samples,
- sizeof(format->multisample_types) * CHAR_BIT));
+ sizeof(format->f.multisample_types) * CHAR_BIT));
for (i = 1; i <= max_log2; ++i)
- format->multisample_types |= 1u << ((1u << i) - 1);
+ format->f.multisample_types |= 1u << ((1u << i) - 1);
}
}
}
static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct wined3d_gl_info *gl_info)
{
- struct wined3d_format *format, *srgb_format;
+ struct wined3d_format_gl *format, *srgb_format;
struct fragment_caps fragment_caps;
struct shader_caps shader_caps;
unsigned int i, j;
@@ -3132,7 +3139,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(adapter, format_texture_info[i].id)))
+ if (!(format = get_format_gl_internal(adapter, format_texture_info[i].id)))
return FALSE;
if (!gl_info->supported[format_texture_info[i].extension])
@@ -3141,62 +3148,62 @@ static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct win
/* ARB_texture_rg defines floating point formats, but only if
* ARB_texture_float is also supported. */
if (!gl_info->supported[ARB_TEXTURE_FLOAT]
- && (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT))
+ && (format->f.flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT))
continue;
/* ARB_texture_rg defines integer formats if EXT_texture_integer is also supported. */
if (!gl_info->supported[EXT_TEXTURE_INTEGER]
- && (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_INTEGER))
+ && (format->f.flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_INTEGER))
continue;
- format->glInternal = format_texture_info[i].gl_internal;
- format->glGammaInternal = format_texture_info[i].gl_srgb_internal;
- format->rtInternal = format_texture_info[i].gl_rt_internal;
- format->glFormat = format_texture_info[i].gl_format;
- format->glType = format_texture_info[i].gl_type;
- format->color_fixup = COLOR_FIXUP_IDENTITY;
- format->height_scale.numerator = 1;
- format->height_scale.denominator = 1;
+ format->internal = format_texture_info[i].gl_internal;
+ format->srgb_internal = format_texture_info[i].gl_srgb_internal;
+ format->rt_internal = format_texture_info[i].gl_rt_internal;
+ format->format = format_texture_info[i].gl_format;
+ format->type = format_texture_info[i].gl_type;
+ format->f.color_fixup = COLOR_FIXUP_IDENTITY;
+ format->f.height_scale.numerator = 1;
+ format->f.height_scale.denominator = 1;
- format->flags[WINED3D_GL_RES_TYPE_TEX_1D] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
- format->flags[WINED3D_GL_RES_TYPE_TEX_2D] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
- format->flags[WINED3D_GL_RES_TYPE_BUFFER] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
+ format->f.flags[WINED3D_GL_RES_TYPE_TEX_1D] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
+ format->f.flags[WINED3D_GL_RES_TYPE_TEX_2D] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
+ format->f.flags[WINED3D_GL_RES_TYPE_BUFFER] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
/* GL_ARB_depth_texture does not support 3D textures. It also says "cube textures are
* problematic", but doesn't explicitly mandate that an error is generated. */
if (gl_info->supported[EXT_TEXTURE3D]
&& !(format_texture_info[i].flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
- format->flags[WINED3D_GL_RES_TYPE_TEX_3D] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
+ format->f.flags[WINED3D_GL_RES_TYPE_TEX_3D] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
- format->flags[WINED3D_GL_RES_TYPE_TEX_CUBE] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
+ format->f.flags[WINED3D_GL_RES_TYPE_TEX_CUBE] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
if (gl_info->supported[ARB_TEXTURE_RECTANGLE])
- format->flags[WINED3D_GL_RES_TYPE_TEX_RECT] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
+ format->f.flags[WINED3D_GL_RES_TYPE_TEX_RECT] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
- format->flags[WINED3D_GL_RES_TYPE_RB] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
- format->flags[WINED3D_GL_RES_TYPE_RB] &= ~WINED3DFMT_FLAG_TEXTURE;
+ format->f.flags[WINED3D_GL_RES_TYPE_RB] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
+ format->f.flags[WINED3D_GL_RES_TYPE_RB] &= ~WINED3DFMT_FLAG_TEXTURE;
- if (format->glGammaInternal != format->glInternal
+ if (format->srgb_internal != format->internal
&& !(adapter->d3d_info.wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL))
{
- format->glGammaInternal = format->glInternal;
- format_clear_flag(format, WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE);
+ format->srgb_internal = format->internal;
+ format_clear_flag(&format->f, WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE);
}
query_internal_format(adapter, format, &format_texture_info[i], gl_info, srgb_write, FALSE);
/* Texture conversion stuff */
- format->conv_byte_count = format_texture_info[i].conv_byte_count;
- format->upload = format_texture_info[i].upload;
- format->download = format_texture_info[i].download;
+ format->f.conv_byte_count = format_texture_info[i].conv_byte_count;
+ format->f.upload = format_texture_info[i].upload;
+ format->f.download = format_texture_info[i].download;
srgb_format = NULL;
for (j = 0; j < ARRAY_SIZE(format_srgb_info); ++j)
{
- if (format_srgb_info[j].base_format_id == format->id)
+ if (format_srgb_info[j].base_format_id == format->f.id)
{
- if (!(srgb_format = get_format_internal(adapter, format_srgb_info[j].srgb_format_id)))
+ if (!(srgb_format = get_format_gl_internal(adapter, format_srgb_info[j].srgb_format_id)))
return FALSE;
break;
}
@@ -3204,14 +3211,14 @@ static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct win
if (!srgb_format)
continue;
- copy_format(adapter, srgb_format, format);
+ copy_format(adapter, &srgb_format->f, &format->f);
if (gl_info->supported[EXT_TEXTURE_SRGB]
&& !(adapter->d3d_info.wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL))
{
- srgb_format->glInternal = format_texture_info[i].gl_srgb_internal;
- srgb_format->glGammaInternal = format_texture_info[i].gl_srgb_internal;
- format_set_flag(srgb_format, WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE);
+ srgb_format->internal = format_texture_info[i].gl_srgb_internal;
+ srgb_format->srgb_internal = format_texture_info[i].gl_srgb_internal;
+ format_set_flag(&srgb_format->f, WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE);
query_internal_format(adapter, srgb_format, &format_texture_info[i], gl_info, srgb_write, TRUE);
}
}
@@ -3335,7 +3342,7 @@ 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;
+ struct wined3d_format_gl *format;
unsigned int i;
static const enum wined3d_format_id fmts16[] =
{
@@ -3373,8 +3380,8 @@ static void init_format_filter_info(struct wined3d_adapter *adapter,
{
for (i = 0; i < ARRAY_SIZE(fmts16); ++i)
{
- format = get_format_internal(adapter, fmts16[i]);
- format_set_flag(format, WINED3DFMT_FLAG_FILTERING);
+ format = get_format_gl_internal(adapter, fmts16[i]);
+ format_set_flag(&format->f, WINED3DFMT_FLAG_FILTERING);
}
}
return;
@@ -3382,19 +3389,19 @@ static void init_format_filter_info(struct wined3d_adapter *adapter,
for (i = 0; i < ARRAY_SIZE(fmts16); ++i)
{
- format = get_format_internal(adapter, fmts16[i]);
- if (!format->glInternal)
+ format = get_format_gl_internal(adapter, fmts16[i]);
+ if (!format->internal)
continue; /* Not supported by GL */
- filtered = check_filter(gl_info, format->glInternal);
+ filtered = check_filter(gl_info, format->internal);
if (filtered)
{
- TRACE("Format %s supports filtering.\n", debug_d3dformat(format->id));
- format_set_flag(format, WINED3DFMT_FLAG_FILTERING);
+ TRACE("Format %s supports filtering.\n", debug_d3dformat(format->f.id));
+ format_set_flag(&format->f, WINED3DFMT_FLAG_FILTERING);
}
else
{
- TRACE("Format %s does not support filtering.\n", debug_d3dformat(format->id));
+ TRACE("Format %s does not support filtering.\n", debug_d3dformat(format->f.id));
}
}
}
@@ -3455,7 +3462,7 @@ static struct color_fixup_desc create_color_fixup_desc_from_string(const char *s
static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_gl_info *gl_info)
{
const struct wined3d_d3d_info *d3d_info = &adapter->d3d_info;
- struct wined3d_format *format;
+ struct wined3d_format_gl *format;
BOOL use_legacy_fixups;
unsigned int i;
@@ -3527,79 +3534,79 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
if (!gl_info->supported[fixups[i].extension])
continue;
- format = get_format_internal(adapter, fixups[i].id);
- format->color_fixup = create_color_fixup_desc_from_string(fixups[i].fixup);
+ format = get_format_gl_internal(adapter, fixups[i].id);
+ format->f.color_fixup = create_color_fixup_desc_from_string(fixups[i].fixup);
}
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])))
{
- format = get_format_internal(adapter, WINED3DFMT_YUY2);
- format->color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YUY2);
+ format = get_format_gl_internal(adapter, WINED3DFMT_YUY2);
+ format->f.color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YUY2);
- format = get_format_internal(adapter, WINED3DFMT_UYVY);
- format->color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_UYVY);
+ format = get_format_gl_internal(adapter, WINED3DFMT_UYVY);
+ format->f.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])))
{
- format = get_format_internal(adapter, WINED3DFMT_YUY2);
- format_clear_flag(format, WINED3DFMT_FLAG_BLIT);
- format->glInternal = 0;
+ format = get_format_gl_internal(adapter, WINED3DFMT_YUY2);
+ format_clear_flag(&format->f, WINED3DFMT_FLAG_BLIT);
+ format->internal = 0;
- format = get_format_internal(adapter, WINED3DFMT_UYVY);
- format_clear_flag(format, WINED3DFMT_FLAG_BLIT);
- format->glInternal = 0;
+ format = get_format_gl_internal(adapter, WINED3DFMT_UYVY);
+ format_clear_flag(&format->f, WINED3DFMT_FLAG_BLIT);
+ format->internal = 0;
}
if (gl_info->supported[ARB_FRAGMENT_PROGRAM]
|| (gl_info->supported[ARB_FRAGMENT_SHADER] && gl_info->supported[ARB_VERTEX_SHADER]))
{
- 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);
+ format = get_format_gl_internal(adapter, WINED3DFMT_YV12);
+ format_set_flag(&format->f, WINED3DFMT_FLAG_HEIGHT_SCALE);
+ format->f.height_scale.numerator = 3;
+ format->f.height_scale.denominator = 2;
+ format->f.color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YV12);
- 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);
+ format = get_format_gl_internal(adapter, WINED3DFMT_NV12);
+ format_set_flag(&format->f, WINED3DFMT_FLAG_HEIGHT_SCALE);
+ format->f.height_scale.numerator = 3;
+ format->f.height_scale.denominator = 2;
+ format->f.color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_NV12);
}
else
{
- format = get_format_internal(adapter, WINED3DFMT_YV12);
- format_clear_flag(format, WINED3DFMT_FLAG_BLIT);
- format->glInternal = 0;
+ format = get_format_gl_internal(adapter, WINED3DFMT_YV12);
+ format_clear_flag(&format->f, WINED3DFMT_FLAG_BLIT);
+ format->internal = 0;
- format = get_format_internal(adapter, WINED3DFMT_NV12);
- format_clear_flag(format, WINED3DFMT_FLAG_BLIT);
- format->glInternal = 0;
+ format = get_format_gl_internal(adapter, WINED3DFMT_NV12);
+ format_clear_flag(&format->f, WINED3DFMT_FLAG_BLIT);
+ format->internal = 0;
}
if (gl_info->supported[ARB_FRAGMENT_PROGRAM] || gl_info->supported[ARB_FRAGMENT_SHADER])
{
- format = get_format_internal(adapter, WINED3DFMT_P8_UINT);
- format->color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_P8);
+ format = get_format_gl_internal(adapter, WINED3DFMT_P8_UINT);
+ format->f.color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_P8);
}
if (!gl_info->supported[ARB_HALF_FLOAT_PIXEL])
{
- format = get_format_internal(adapter, WINED3DFMT_R16_FLOAT);
- format_clear_flag(format, WINED3DFMT_FLAG_TEXTURE);
+ format = get_format_gl_internal(adapter, WINED3DFMT_R16_FLOAT);
+ format_clear_flag(&format->f, WINED3DFMT_FLAG_TEXTURE);
- format = get_format_internal(adapter, WINED3DFMT_R16G16_FLOAT);
- format_clear_flag(format, WINED3DFMT_FLAG_TEXTURE);
+ format = get_format_gl_internal(adapter, WINED3DFMT_R16G16_FLOAT);
+ format_clear_flag(&format->f, WINED3DFMT_FLAG_TEXTURE);
- format = get_format_internal(adapter, WINED3DFMT_R16G16B16A16_FLOAT);
- format_clear_flag(format, WINED3DFMT_FLAG_TEXTURE);
+ format = get_format_gl_internal(adapter, WINED3DFMT_R16G16B16A16_FLOAT);
+ format_clear_flag(&format->f, WINED3DFMT_FLAG_TEXTURE);
}
if (gl_info->quirks & WINED3D_QUIRK_BROKEN_RGBA16)
{
- format = get_format_internal(adapter, WINED3DFMT_R16G16B16A16_UNORM);
- format_clear_flag(format, WINED3DFMT_FLAG_TEXTURE);
+ format = get_format_gl_internal(adapter, WINED3DFMT_R16G16B16A16_UNORM);
+ format_clear_flag(&format->f, WINED3DFMT_FLAG_TEXTURE);
}
/* ATI instancing hack: Although ATI cards do not support Shader Model
@@ -3617,8 +3624,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])
{
- format = get_format_internal(adapter, WINED3DFMT_INST);
- format_set_flag(format, WINED3DFMT_FLAG_TEXTURE);
+ format = get_format_gl_internal(adapter, WINED3DFMT_INST);
+ format_set_flag(&format->f, WINED3DFMT_FLAG_TEXTURE);
}
/* Depth bound test. To query if the card supports it CheckDeviceFormat()
@@ -3629,8 +3636,8 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
* value. */
if (gl_info->supported[EXT_DEPTH_BOUNDS_TEST])
{
- format = get_format_internal(adapter, WINED3DFMT_NVDB);
- format_set_flag(format, WINED3DFMT_FLAG_TEXTURE);
+ format = get_format_gl_internal(adapter, WINED3DFMT_NVDB);
+ format_set_flag(&format->f, WINED3DFMT_FLAG_TEXTURE);
}
/* RESZ aka AMD DX9-level hack for multisampled depth buffer resolve. You query for RESZ
@@ -3638,27 +3645,27 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
* RENDERTARGET usage. */
if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
{
- format = get_format_internal(adapter, WINED3DFMT_RESZ);
- format_set_flag(format, WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_RENDERTARGET);
+ format = get_format_gl_internal(adapter, WINED3DFMT_RESZ);
+ format_set_flag(&format->f, WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_RENDERTARGET);
}
for (i = 0; i < WINED3D_FORMAT_COUNT; ++i)
{
- struct wined3d_format *format = get_format_by_idx(adapter, i);
+ format = get_format_gl_by_idx(adapter, i);
- if (!(format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_TEXTURE))
+ if (!(format->f.flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_TEXTURE))
continue;
- if (is_identity_fixup(format->color_fixup))
+ if (is_identity_fixup(format->f.color_fixup))
continue;
TRACE("Checking support for fixup:\n");
- dump_color_fixup_desc(format->color_fixup);
- if (!adapter->shader_backend->shader_color_fixup_supported(format->color_fixup)
- || !adapter->fragment_pipe->color_fixup_supported(format->color_fixup))
+ dump_color_fixup_desc(format->f.color_fixup);
+ if (!adapter->shader_backend->shader_color_fixup_supported(format->f.color_fixup)
+ || !adapter->fragment_pipe->color_fixup_supported(format->f.color_fixup))
{
TRACE("[FAILED]\n");
- format_clear_flag(format, WINED3DFMT_FLAG_TEXTURE);
+ format_clear_flag(&format->f, WINED3DFMT_FLAG_TEXTURE);
}
else
{
@@ -3668,18 +3675,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. */
- 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;
+ format = get_format_gl_internal(adapter, WINED3DFMT_ATI1N);
+ format->f.flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
+ format = get_format_gl_internal(adapter, WINED3DFMT_ATI2N);
+ format->f.flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
+ format = get_format_gl_internal(adapter, WINED3DFMT_BC4_UNORM);
+ format->f.flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
+ format = get_format_gl_internal(adapter, WINED3DFMT_BC4_SNORM);
+ format->f.flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
+ format = get_format_gl_internal(adapter, WINED3DFMT_BC5_UNORM);
+ format->f.flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
+ format = get_format_gl_internal(adapter, WINED3DFMT_BC5_SNORM);
+ format->f.flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
}
static BOOL init_format_vertex_info(const struct wined3d_adapter *adapter,
@@ -3936,22 +3943,22 @@ static void init_format_depth_bias_scale(struct wined3d_adapter *adapter,
for (i = 0; i < WINED3D_FORMAT_COUNT; ++i)
{
- struct wined3d_format *format = get_format_by_idx(adapter, i);
+ struct wined3d_format_gl *format = get_format_gl_by_idx(adapter, i);
- if (format->flags[WINED3D_GL_RES_TYPE_RB] & WINED3DFMT_FLAG_DEPTH)
+ if (format->f.flags[WINED3D_GL_RES_TYPE_RB] & WINED3DFMT_FLAG_DEPTH)
{
- TRACE("Testing depth bias scale for format %s.\n", debug_d3dformat(format->id));
- format->depth_bias_scale = wined3d_adapter_find_polyoffset_scale(ctx, format->glInternal);
+ TRACE("Testing depth bias scale for format %s.\n", debug_d3dformat(format->f.id));
+ format->f.depth_bias_scale = wined3d_adapter_find_polyoffset_scale(ctx, format->internal);
if (!(d3d_info->wined3d_creation_flags & WINED3D_NORMALIZED_DEPTH_BIAS))
{
/* The single-precision binary floating-point format has
* a significand precision of 24 bits.
*/
- if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT)
- format->depth_bias_scale /= 1u << 24;
+ if (format->f.flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT)
+ format->f.depth_bias_scale /= 1u << 24;
else
- format->depth_bias_scale /= 1u << format->depth_size;
+ format->f.depth_bias_scale /= 1u << format->f.depth_size;
}
}
}
diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c
index dedb9fc8047..ff284684089 100644
--- a/dlls/wined3d/view.c
+++ b/dlls/wined3d/view.c
@@ -169,11 +169,13 @@ static void create_texture_view(struct wined3d_gl_view *view, GLenum view_target
const struct wined3d_view_desc *desc, struct wined3d_texture *texture,
const struct wined3d_format *view_format)
{
+ const struct wined3d_format_gl *view_format_gl;
unsigned int level_idx, layer_idx, layer_count;
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
GLuint texture_name;
+ view_format_gl = wined3d_format_gl(view_format);
view->target = view_target;
context = context_acquire(texture->resource.device, NULL, 0);
@@ -201,11 +203,11 @@ static void create_texture_view(struct wined3d_gl_view *view, GLenum view_target
}
gl_info->gl_ops.gl.p_glGenTextures(1, &view->name);
- GL_EXTCALL(glTextureView(view->name, view->target, texture_name, view_format->glInternal,
+ GL_EXTCALL(glTextureView(view->name, view->target, texture_name, view_format_gl->internal,
level_idx, desc->u.texture.level_count, layer_idx, layer_count));
checkGLcall("create texture view");
- if (is_stencil_view_format(view_format))
+ if (is_stencil_view_format(&view_format_gl->f))
{
static const GLint swizzle[] = {GL_ZERO, GL_RED, GL_ZERO, GL_ZERO};
@@ -233,6 +235,7 @@ static void create_buffer_texture(struct wined3d_gl_view *view, struct wined3d_c
unsigned int offset, unsigned int size)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
+ const struct wined3d_format_gl *view_format_gl;
if (!gl_info->supported[ARB_TEXTURE_BUFFER_OBJECT])
{
@@ -247,6 +250,7 @@ static void create_buffer_texture(struct wined3d_gl_view *view, struct wined3d_c
return;
}
+ view_format_gl = wined3d_format_gl(view_format);
wined3d_buffer_load_location(buffer, context, WINED3D_LOCATION_BUFFER);
view->target = GL_TEXTURE_BUFFER;
@@ -255,14 +259,14 @@ static void create_buffer_texture(struct wined3d_gl_view *view, struct wined3d_c
context_bind_texture(context, GL_TEXTURE_BUFFER, view->name);
if (gl_info->supported[ARB_TEXTURE_BUFFER_RANGE])
{
- GL_EXTCALL(glTexBufferRange(GL_TEXTURE_BUFFER, view_format->glInternal,
+ GL_EXTCALL(glTexBufferRange(GL_TEXTURE_BUFFER, view_format_gl->internal,
buffer->buffer_object, offset, size));
}
else
{
if (offset || size != buffer->resource.size)
FIXME("OpenGL implementation does not support ARB_texture_buffer_range.\n");
- GL_EXTCALL(glTexBuffer(GL_TEXTURE_BUFFER, view_format->glInternal, buffer->buffer_object));
+ GL_EXTCALL(glTexBuffer(GL_TEXTURE_BUFFER, view_format_gl->internal, buffer->buffer_object));
}
checkGLcall("Create buffer texture");
@@ -1006,7 +1010,7 @@ void wined3d_unordered_access_view_clear_uint(struct wined3d_unordered_access_vi
const struct wined3d_uvec4 *clear_value, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
- const struct wined3d_format *format;
+ const struct wined3d_format_gl *format;
struct wined3d_resource *resource;
struct wined3d_buffer *buffer;
unsigned int offset, size;
@@ -1024,12 +1028,12 @@ void wined3d_unordered_access_view_clear_uint(struct wined3d_unordered_access_vi
return;
}
- format = view->format;
- if (format->id != WINED3DFMT_R32_UINT && format->id != WINED3DFMT_R32_SINT
- && format->id != WINED3DFMT_R32G32B32A32_UINT
- && format->id != WINED3DFMT_R32G32B32A32_SINT)
+ format = wined3d_format_gl(view->format);
+ if (format->f.id != WINED3DFMT_R32_UINT && format->f.id != WINED3DFMT_R32_SINT
+ && format->f.id != WINED3DFMT_R32G32B32A32_UINT
+ && format->f.id != WINED3DFMT_R32G32B32A32_SINT)
{
- FIXME("Not implemented for format %s.\n", debug_d3dformat(format->id));
+ FIXME("Not implemented for format %s.\n", debug_d3dformat(format->f.id));
return;
}
@@ -1037,10 +1041,10 @@ void wined3d_unordered_access_view_clear_uint(struct wined3d_unordered_access_vi
wined3d_buffer_load_location(buffer, context, WINED3D_LOCATION_BUFFER);
wined3d_unordered_access_view_invalidate_location(view, ~WINED3D_LOCATION_BUFFER);
- get_buffer_view_range(buffer, &view->desc, format, &offset, &size);
+ get_buffer_view_range(buffer, &view->desc, &format->f, &offset, &size);
context_bind_bo(context, buffer->buffer_type_hint, buffer->buffer_object);
- GL_EXTCALL(glClearBufferSubData(buffer->buffer_type_hint, format->glInternal,
- offset, size, format->glFormat, format->glType, clear_value));
+ GL_EXTCALL(glClearBufferSubData(buffer->buffer_type_hint, format->internal,
+ offset, size, format->format, format->type, clear_value));
checkGLcall("clear unordered access view");
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index cec2cfff330..4c5d73f677e 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -4339,11 +4339,6 @@ struct wined3d_format
enum wined3d_ffp_emit_idx emit_idx;
- GLint glInternal;
- GLint glGammaInternal;
- GLint rtInternal;
- GLint glFormat;
- GLint glType;
UINT conv_byte_count;
DWORD multisample_types;
unsigned int flags[WINED3D_GL_RES_TYPE_COUNT];
@@ -4387,6 +4382,12 @@ struct wined3d_format_gl
GLenum vtx_type;
GLint vtx_format;
+ GLint internal;
+ GLint srgb_internal;
+ GLint rt_internal;
+ GLint format;
+ GLint type;
+
GLenum view_class;
};
--
2.11.0
Sept. 21, 2018
[PATCH 4/5] wined3d: Introduce WINED3DFMT_FLAG_BLIT.
by Henri Verbeet
To indicate whether a particular format can be used for "off-screen plain"
surfaces.
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/directx.c | 40 +++-------------------------
dlls/wined3d/utils.c | 59 +++++++++++++++++++++++++++++++++++++-----
dlls/wined3d/wined3d_private.h | 2 ++
3 files changed, 58 insertions(+), 43 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 89684477e68..02ca3f6f04b 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -1474,41 +1474,9 @@ static BOOL CheckRenderTargetCapability(const struct wined3d_adapter *adapter,
return FALSE;
}
-static BOOL wined3d_check_surface_capability(const struct wined3d_format *format, BOOL no3d)
+static BOOL wined3d_check_surface_capability(const struct wined3d_format *format)
{
- if (no3d)
- {
- switch (format->id)
- {
- case WINED3DFMT_B8G8R8_UNORM:
- TRACE("[FAILED] - Not enumerated on Windows.\n");
- return FALSE;
- case WINED3DFMT_B8G8R8A8_UNORM:
- case WINED3DFMT_B8G8R8X8_UNORM:
- case WINED3DFMT_B5G6R5_UNORM:
- case WINED3DFMT_B5G5R5X1_UNORM:
- case WINED3DFMT_B5G5R5A1_UNORM:
- case WINED3DFMT_B4G4R4A4_UNORM:
- case WINED3DFMT_B2G3R3_UNORM:
- case WINED3DFMT_A8_UNORM:
- case WINED3DFMT_B2G3R3A8_UNORM:
- case WINED3DFMT_B4G4R4X4_UNORM:
- case WINED3DFMT_R10G10B10A2_UNORM:
- case WINED3DFMT_R8G8B8A8_UNORM:
- case WINED3DFMT_R8G8B8X8_UNORM:
- case WINED3DFMT_R16G16_UNORM:
- case WINED3DFMT_B10G10R10A2_UNORM:
- case WINED3DFMT_R16G16B16A16_UNORM:
- case WINED3DFMT_P8_UINT:
- TRACE("[OK]\n");
- return TRUE;
- default:
- TRACE("[FAILED] - Not available on GDI surfaces.\n");
- return FALSE;
- }
- }
-
- if (format->glInternal)
+ if ((format->flags[WINED3D_GL_RES_TYPE_TEX_2D] | format->flags[WINED3D_GL_RES_TYPE_RB]) & WINED3DFMT_FLAG_BLIT)
{
TRACE("[OK]\n");
return TRUE;
@@ -1589,7 +1557,7 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad
allowed_usage |= WINED3DUSAGE_QUERY_SRGBWRITE;
if (!(usage & WINED3DUSAGE_TEXTURE))
{
- if (!wined3d_check_surface_capability(format, wined3d->flags & WINED3D_NO3D))
+ if (!wined3d_check_surface_capability(format))
{
TRACE("[FAILED] - Not supported for plain surfaces.\n");
return WINED3DERR_NOTAVAILABLE;
@@ -2490,7 +2458,7 @@ static BOOL wined3d_adapter_no3d_init(struct wined3d_adapter *adapter)
adapter->vram_bytes_used = 0;
TRACE("Emulating 0x%s bytes of video ram.\n", wine_dbgstr_longlong(adapter->vram_bytes));
- if (!wined3d_adapter_init_format_info(adapter, sizeof(struct wined3d_format)))
+ if (!wined3d_adapter_no3d_init_format_info(adapter))
return FALSE;
adapter->vertex_pipe = &none_vertex_pipe;
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 8e9b6dfafd6..36694856081 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -3158,23 +3158,23 @@ static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct win
format->height_scale.numerator = 1;
format->height_scale.denominator = 1;
- format->flags[WINED3D_GL_RES_TYPE_TEX_1D] |= format_texture_info[i].flags;
- format->flags[WINED3D_GL_RES_TYPE_TEX_2D] |= format_texture_info[i].flags;
- format->flags[WINED3D_GL_RES_TYPE_BUFFER] |= format_texture_info[i].flags;
+ format->flags[WINED3D_GL_RES_TYPE_TEX_1D] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
+ format->flags[WINED3D_GL_RES_TYPE_TEX_2D] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
+ format->flags[WINED3D_GL_RES_TYPE_BUFFER] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
/* GL_ARB_depth_texture does not support 3D textures. It also says "cube textures are
* problematic", but doesn't explicitly mandate that an error is generated. */
if (gl_info->supported[EXT_TEXTURE3D]
&& !(format_texture_info[i].flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
- format->flags[WINED3D_GL_RES_TYPE_TEX_3D] |= format_texture_info[i].flags;
+ format->flags[WINED3D_GL_RES_TYPE_TEX_3D] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
- format->flags[WINED3D_GL_RES_TYPE_TEX_CUBE] |= format_texture_info[i].flags;
+ format->flags[WINED3D_GL_RES_TYPE_TEX_CUBE] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
if (gl_info->supported[ARB_TEXTURE_RECTANGLE])
- format->flags[WINED3D_GL_RES_TYPE_TEX_RECT] |= format_texture_info[i].flags;
+ format->flags[WINED3D_GL_RES_TYPE_TEX_RECT] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
- format->flags[WINED3D_GL_RES_TYPE_RB] |= format_texture_info[i].flags;
+ format->flags[WINED3D_GL_RES_TYPE_RB] |= format_texture_info[i].flags | WINED3DFMT_FLAG_BLIT;
format->flags[WINED3D_GL_RES_TYPE_RB] &= ~WINED3DFMT_FLAG_TEXTURE;
if (format->glGammaInternal != format->glInternal
@@ -3544,9 +3544,11 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
&& (!gl_info->supported[ARB_FRAGMENT_SHADER] || !gl_info->supported[ARB_VERTEX_SHADER])))
{
format = get_format_internal(adapter, WINED3DFMT_YUY2);
+ format_clear_flag(format, WINED3DFMT_FLAG_BLIT);
format->glInternal = 0;
format = get_format_internal(adapter, WINED3DFMT_UYVY);
+ format_clear_flag(format, WINED3DFMT_FLAG_BLIT);
format->glInternal = 0;
}
@@ -3568,9 +3570,11 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
else
{
format = get_format_internal(adapter, WINED3DFMT_YV12);
+ format_clear_flag(format, WINED3DFMT_FLAG_BLIT);
format->glInternal = 0;
format = get_format_internal(adapter, WINED3DFMT_NV12);
+ format_clear_flag(format, WINED3DFMT_FLAG_BLIT);
format->glInternal = 0;
}
@@ -3979,6 +3983,47 @@ fail:
return FALSE;
}
+BOOL wined3d_adapter_no3d_init_format_info(struct wined3d_adapter *adapter)
+{
+ struct wined3d_format *format;
+ unsigned int i;
+
+ static const enum wined3d_format_id blit_formats[] =
+ {
+ WINED3DFMT_B8G8R8A8_UNORM,
+ WINED3DFMT_B8G8R8X8_UNORM,
+ WINED3DFMT_B5G6R5_UNORM,
+ WINED3DFMT_B5G5R5X1_UNORM,
+ WINED3DFMT_B5G5R5A1_UNORM,
+ WINED3DFMT_B4G4R4A4_UNORM,
+ WINED3DFMT_B2G3R3_UNORM,
+ WINED3DFMT_A8_UNORM,
+ WINED3DFMT_B2G3R3A8_UNORM,
+ WINED3DFMT_B4G4R4X4_UNORM,
+ WINED3DFMT_R10G10B10A2_UNORM,
+ WINED3DFMT_R8G8B8A8_UNORM,
+ WINED3DFMT_R8G8B8X8_UNORM,
+ WINED3DFMT_R16G16_UNORM,
+ WINED3DFMT_B10G10R10A2_UNORM,
+ WINED3DFMT_R16G16B16A16_UNORM,
+ WINED3DFMT_P8_UINT,
+ };
+
+ if (!wined3d_adapter_init_format_info(adapter, sizeof(struct wined3d_format)))
+ return FALSE;
+
+ for (i = 0; i < ARRAY_SIZE(blit_formats); ++i)
+ {
+ if (!(format = get_format_internal(adapter, blit_formats[i])))
+ return FALSE;
+
+ format->flags[WINED3D_GL_RES_TYPE_TEX_2D] |= WINED3DFMT_FLAG_BLIT;
+ format->flags[WINED3D_GL_RES_TYPE_RB] |= WINED3DFMT_FLAG_BLIT;
+ }
+
+ return TRUE;
+}
+
/* Context activation is done by the caller. */
BOOL wined3d_adapter_gl_init_format_info(struct wined3d_adapter *adapter, struct wined3d_caps_gl_ctx *ctx)
{
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index cb2f44212c4..cec2cfff330 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2695,6 +2695,7 @@ struct wined3d_caps_gl_ctx
BOOL wined3d_adapter_init_format_info(struct wined3d_adapter *adapter, size_t format_size) DECLSPEC_HIDDEN;
BOOL wined3d_adapter_gl_init_format_info(struct wined3d_adapter *adapter,
struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN;
+BOOL wined3d_adapter_no3d_init_format_info(struct wined3d_adapter *adapter) DECLSPEC_HIDDEN;
UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount) DECLSPEC_HIDDEN;
BOOL wined3d_caps_gl_ctx_test_viewport_subpixel_bits(struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN;
@@ -4299,6 +4300,7 @@ extern enum wined3d_format_id pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN
#define WINED3DFMT_FLAG_GEN_MIPMAP 0x00400000
#define WINED3DFMT_FLAG_NORMALISED 0x00800000
#define WINED3DFMT_FLAG_VERTEX_ATTRIBUTE 0x01000000
+#define WINED3DFMT_FLAG_BLIT 0x02000000
struct wined3d_rational
{
--
2.11.0
Sept. 21, 2018