Wine-devel
Threads by month
- ----- 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
May 2021
- 86 participants
- 705 discussions
[PATCH 1/2] qedit/tests: Check the Sample Grabber's buffer during and after flushing.
by Gabriel Ivăncescu 04 Oct '22
by Gabriel Ivăncescu 04 Oct '22
04 Oct '22
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com>
---
dlls/qedit/tests/samplegrabber.c | 234 +++++++++++++++++++++++++++++++
1 file changed, 234 insertions(+)
diff --git a/dlls/qedit/tests/samplegrabber.c b/dlls/qedit/tests/samplegrabber.c
index 8e68e3e..e66180f 100644
--- a/dlls/qedit/tests/samplegrabber.c
+++ b/dlls/qedit/tests/samplegrabber.c
@@ -1036,6 +1036,239 @@ static void test_connect_pin(void)
ok(!ref, "Got outstanding refcount %d.\n", ref);
}
+struct frame_thread_params
+{
+ IMemInputPin *sink;
+ IMediaSample *sample;
+ DWORD delay;
+};
+
+static DWORD WINAPI frame_thread(void *arg)
+{
+ struct frame_thread_params *params = arg;
+ HRESULT hr;
+
+ if (params->delay)
+ {
+ if (winetest_debug > 1) trace("%04x: Sleeping %u ms.\n", GetCurrentThreadId(), params->delay);
+ Sleep(params->delay);
+ }
+ if (winetest_debug > 1) trace("%04x: Sending frame.\n", GetCurrentThreadId());
+ hr = IMemInputPin_Receive(params->sink, params->sample);
+ if (winetest_debug > 1) trace("%04x: Returned %#x.\n", GetCurrentThreadId(), hr);
+ IMediaSample_Release(params->sample);
+ free(params);
+ return hr;
+}
+
+static HANDLE send_frame_time(IMemInputPin *sink, REFERENCE_TIME start_time, unsigned char color, DWORD delay)
+{
+ struct frame_thread_params *params = malloc(sizeof(*params));
+ IMemAllocator *allocator;
+ REFERENCE_TIME end_time;
+ IMediaSample *sample;
+ HANDLE thread;
+ HRESULT hr;
+ BYTE *data;
+
+ hr = IMemInputPin_GetAllocator(sink, &allocator);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
+ if (hr == VFW_E_NOT_COMMITTED)
+ {
+ IMemAllocator_Commit(allocator);
+ hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
+ }
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMediaSample_GetPointer(sample, &data);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ memset(data, 0x55, 32 * 16 * 2);
+
+ hr = IMediaSample_SetActualDataLength(sample, 32 * 16 * 2);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ start_time *= 10000000;
+ end_time = start_time + 10000000;
+ hr = IMediaSample_SetTime(sample, &start_time, &end_time);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ params->sink = sink;
+ params->sample = sample;
+ params->delay = delay;
+ thread = CreateThread(NULL, 0, frame_thread, params, 0, NULL);
+
+ IMemAllocator_Release(allocator);
+ return thread;
+}
+
+static HANDLE send_frame(IMemInputPin *sink, DWORD delay)
+{
+ return send_frame_time(sink, 0, 0x55, delay); /* purple */
+}
+
+static HRESULT join_thread_(int line, HANDLE thread)
+{
+ DWORD ret;
+ ok_(__FILE__, line)(!WaitForSingleObject(thread, 1000), "Wait failed.\n");
+ GetExitCodeThread(thread, &ret);
+ CloseHandle(thread);
+ return ret;
+}
+#define join_thread(a) join_thread_(__LINE__, a)
+
+static void test_buffer_flush(void)
+{
+ AM_MEDIA_TYPE req_mt =
+ {
+ .majortype = MEDIATYPE_Video,
+ .subtype = MEDIASUBTYPE_RGB565,
+ .formattype = FORMAT_VideoInfo,
+ .bTemporalCompression = TRUE,
+ };
+ LONG buf[(32 * 16 * 2) / sizeof(LONG)], size = sizeof(buf);
+ IPin *sink, *source, *renderer_pin;
+ struct testfilter testsource;
+ ISampleGrabber *grabber;
+ IMediaControl *control;
+ IFilterGraph2 *graph;
+ IMemInputPin *input;
+ IBaseFilter *filter;
+ OAFilterState state;
+ IMediaFilter *mf;
+ HANDLE thread;
+ DWORD ticks;
+ unsigned i;
+ HRESULT hr;
+ ULONG ref;
+
+ testfilter_init(&testsource);
+ CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IFilterGraph2, (void **)&graph);
+ CoCreateInstance(&CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IBaseFilter, (void **)&filter);
+ IFilterGraph2_AddFilter(graph, filter, L"sink");
+ IBaseFilter_FindPin(filter, L"In", &renderer_pin);
+ IBaseFilter_Release(filter);
+
+ filter = create_sample_grabber();
+ IFilterGraph2_AddFilter(graph, &testsource.filter.IBaseFilter_iface, L"source");
+ IFilterGraph2_AddFilter(graph, filter, L"sample grabber");
+ IBaseFilter_FindPin(filter, L"In", &sink);
+ IBaseFilter_FindPin(filter, L"Out", &source);
+ IBaseFilter_QueryInterface(filter, &IID_ISampleGrabber, (void **)&grabber);
+ IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control);
+ IPin_QueryInterface(sink, &IID_IMemInputPin, (void **)&input);
+
+ ISampleGrabber_SetMediaType(grabber, &req_mt);
+ ISampleGrabber_SetBufferSamples(grabber, TRUE);
+
+ testsource.sink_mt = &req_mt;
+ hr = IFilterGraph2_ConnectDirect(graph, &testsource.source.pin.IPin_iface, sink, &req_mt);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IFilterGraph2_ConnectDirect(graph, source, renderer_pin, &req_mt);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ IPin_Release(renderer_pin);
+
+ IFilterGraph2_QueryInterface(graph, &IID_IMediaFilter, (void **)&mf);
+ IMediaFilter_SetSyncSource(mf, NULL);
+ IMediaFilter_Release(mf);
+
+ hr = IMemInputPin_ReceiveCanBlock(input);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = ISampleGrabber_GetCurrentBuffer(grabber, &size, buf);
+ ok(hr == VFW_E_WRONG_STATE, "Got hr %#x.\n", hr);
+
+ hr = IMediaControl_Pause(control);
+ ok(hr == S_FALSE, "Got hr %#x.\n", hr);
+ hr = IMediaControl_GetState(control, 0, &state);
+ ok(hr == VFW_S_STATE_INTERMEDIATE, "Got hr %#x.\n", hr);
+
+ thread = send_frame(input, 0);
+ hr = IMediaControl_GetState(control, 1000, &state);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(WaitForSingleObject(thread, 100) == WAIT_TIMEOUT, "Thread should block in Receive().\n");
+
+ for (i = 0; i < 3; i++)
+ {
+ ticks = GetTickCount();
+ hr = ISampleGrabber_GetCurrentBuffer(grabber, &size, buf);
+ ticks = GetTickCount() - ticks;
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(ticks < 100, "Got %u ticks.\n", ticks);
+ ok(size == sizeof(buf), "Got size %d.\n", size);
+ }
+
+ hr = IMediaControl_Stop(control);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = join_thread(thread);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IMediaControl_GetState(control, 1000, &state);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(state == State_Stopped, "Got state %d.\n", state);
+ hr = ISampleGrabber_GetCurrentBuffer(grabber, &size, buf);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMediaControl_Pause(control);
+ ok(hr == S_FALSE, "Got hr %#x.\n", hr);
+ hr = IMediaControl_GetState(control, 0, &state);
+ ok(hr == VFW_S_STATE_INTERMEDIATE, "Got hr %#x.\n", hr);
+
+ thread = send_frame(input, 0);
+ hr = IMediaControl_GetState(control, 1000, &state);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(WaitForSingleObject(thread, 100) == WAIT_TIMEOUT, "Thread should block in Receive().\n");
+
+ for (i = 0; i < 3; i++)
+ {
+ ticks = GetTickCount();
+ hr = ISampleGrabber_GetCurrentBuffer(grabber, &size, buf);
+ ticks = GetTickCount() - ticks;
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(ticks < 100, "Got %u ticks.\n", ticks);
+ ok(size == sizeof(buf), "Got size %d.\n", size);
+ }
+
+ IPin_BeginFlush(sink);
+ hr = join_thread(thread);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = ISampleGrabber_GetCurrentBuffer(grabber, &size, buf);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ IPin_EndFlush(sink);
+
+ hr = IMediaControl_GetState(control, 0, &state);
+ todo_wine ok(hr == VFW_S_STATE_INTERMEDIATE, "Got hr %#x.\n", hr);
+
+ ticks = GetTickCount();
+ thread = send_frame(input, 150);
+ hr = ISampleGrabber_GetCurrentBuffer(grabber, &size, buf);
+ ticks = GetTickCount() - ticks;
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(ticks < 100, "Got %u ticks.\n", ticks);
+ ok(size == sizeof(buf), "Got size %d.\n", size);
+
+ hr = IMediaControl_GetState(control, 1000, &state);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IMediaControl_Stop(control);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = join_thread(thread);
+ todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ IPin_Release(sink);
+ IPin_Release(source);
+ IMemInputPin_Release(input);
+ IMediaControl_Release(control);
+ ref = IFilterGraph2_Release(graph);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ISampleGrabber_Release(grabber);
+ ref = IBaseFilter_Release(filter);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ref = IBaseFilter_Release(&testsource.filter.IBaseFilter_iface);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+}
+
START_TEST(samplegrabber)
{
IBaseFilter *filter;
@@ -1059,6 +1292,7 @@ START_TEST(samplegrabber)
test_aggregation();
test_media_types();
test_connect_pin();
+ test_buffer_flush();
CoUninitialize();
}
--
2.21.0
5
7
Based on the DXVA AV1 specs
https://www.microsoft.com/en-us/download/details.aspx?id=101577
The structures and the associated define are available in Windows SDK
since at least 10.0.20231.0.
The GUIDs were present in previous SDKs as well.
---
include/dxva.h | 279 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 279 insertions(+)
diff --git a/include/dxva.h b/include/dxva.h
index 4f18f2e60da..b474bd87111 100644
--- a/include/dxva.h
+++ b/include/dxva.h
@@ -563,6 +563,285 @@ typedef struct _DXVA_Status_VPx
USHORT wNumMbsAffected;
} DXVA_Status_VPx, *LPDXVA_Status_VPx;
+
+#define _DIRECTX_AV1_VA_
+
+/* AV1 decoder GUIDs */
+DEFINE_GUID(DXVA_ModeAV1_VLD_Profile0, 0xb8be4ccb, 0xcf53, 0x46ba, 0x8d, 0x59, 0xd6, 0xb8, 0xa6, 0xda, 0x5d, 0x2a);
+DEFINE_GUID(DXVA_ModeAV1_VLD_Profile1, 0x6936ff0f, 0x45b1, 0x4163, 0x9c, 0xc1, 0x64, 0x6e, 0xf6, 0x94, 0x61, 0x08);
+DEFINE_GUID(DXVA_ModeAV1_VLD_Profile2, 0x0c5f2aa1, 0xe541, 0x4089, 0xbb, 0x7b, 0x98, 0x11, 0x0a, 0x19, 0xd7, 0xc8);
+DEFINE_GUID(DXVA_ModeAV1_VLD_12bit_Profile2, 0x17127009, 0xa00f, 0x4ce1, 0x99, 0x4e, 0xbf, 0x40, 0x81, 0xf6, 0xf3, 0xf0);
+DEFINE_GUID(DXVA_ModeAV1_VLD_12bit_Profile2_420, 0x2d80bed6, 0x9cac, 0x4835, 0x9e, 0x91, 0x32, 0x7b, 0xbc, 0x4f, 0x9e, 0xe8);
+
+/* AV1 picture entry data structure */
+typedef struct _DXVA_PicEntry_AV1 {
+ UINT width;
+ UINT height;
+
+ // Global motion parameters
+ INT wmmat[6];
+ union {
+ struct {
+ UCHAR wminvalid : 1;
+ UCHAR wmtype : 2;
+ UCHAR Reserved : 5;
+ };
+ UCHAR GlobalMotionFlags;
+ };
+ UCHAR Index;
+ USHORT Reserved16Bits;
+} DXVA_PicEntry_AV1, *LPDXVA_PicEntry_AV1;
+
+/* AV1 picture parameters data structure */
+typedef struct _DXVA_PicParams_AV1 {
+ UINT width;
+ UINT height;
+
+ UINT max_width;
+ UINT max_height;
+
+ UCHAR CurrPicTextureIndex;
+ UCHAR superres_denom;
+ UCHAR bitdepth;
+ UCHAR seq_profile;
+
+ // Tiles:
+ struct {
+ UCHAR cols;
+ UCHAR rows;
+ USHORT context_update_id;
+ USHORT widths[64];
+ USHORT heights[64];
+ } tiles;
+
+ // Coding Tools
+ union {
+ struct {
+ UINT use_128x128_superblock : 1;
+ UINT intra_edge_filter : 1;
+ UINT interintra_compound : 1;
+ UINT masked_compound : 1;
+ UINT warped_motion : 1;
+ UINT dual_filter : 1;
+ UINT jnt_comp : 1;
+ UINT screen_content_tools : 1;
+ UINT integer_mv : 1;
+ UINT cdef : 1;
+ UINT restoration : 1;
+ UINT film_grain : 1;
+ UINT intrabc : 1;
+ UINT high_precision_mv : 1;
+ UINT switchable_motion_mode : 1;
+ UINT filter_intra : 1;
+ UINT disable_frame_end_update_cdf : 1;
+ UINT disable_cdf_update : 1;
+ UINT reference_mode : 1;
+ UINT skip_mode : 1;
+ UINT reduced_tx_set : 1;
+ UINT superres : 1;
+ UINT tx_mode : 2;
+ UINT use_ref_frame_mvs : 1;
+ UINT enable_ref_frame_mvs : 1;
+ UINT reference_frame_update : 1;
+ UINT Reserved : 5;
+ };
+ UINT32 CodingParamToolFlags;
+ } coding;
+
+ // Format & Picture Info flags
+ union {
+ struct {
+ UCHAR frame_type : 2;
+ UCHAR show_frame : 1;
+ UCHAR showable_frame : 1;
+ UCHAR subsampling_x : 1;
+ UCHAR subsampling_y : 1;
+ UCHAR mono_chrome : 1;
+ UCHAR Reserved : 1;
+ };
+ UCHAR FormatAndPictureInfoFlags;
+ } format;
+
+ // References
+ UCHAR primary_ref_frame;
+ UCHAR order_hint;
+ UCHAR order_hint_bits;
+
+ DXVA_PicEntry_AV1 frame_refs[7];
+ UCHAR RefFrameMapTextureIndex[8];
+
+ // Loop filter parameters
+ struct {
+ UCHAR filter_level[2];
+ UCHAR filter_level_u;
+ UCHAR filter_level_v;
+
+ UCHAR sharpness_level;
+ union {
+ struct {
+ UCHAR mode_ref_delta_enabled : 1;
+ UCHAR mode_ref_delta_update : 1;
+ UCHAR delta_lf_multi : 1;
+ UCHAR delta_lf_present : 1;
+ UCHAR Reserved : 4;
+ };
+ UCHAR ControlFlags;
+ } DUMMYUNIONNAME;
+ CHAR ref_deltas[8];
+ CHAR mode_deltas[2];
+ UCHAR delta_lf_res;
+ UCHAR frame_restoration_type[3];
+ USHORT log2_restoration_unit_size[3];
+ UINT16 Reserved16Bits;
+ } loop_filter;
+
+ // Quantization
+ struct {
+ union {
+ struct {
+ UCHAR delta_q_present : 1;
+ UCHAR delta_q_res : 2;
+ UCHAR Reserved : 5;
+ };
+ UCHAR ControlFlags;
+ } DUMMYUNIONNAME;
+
+ UCHAR base_qindex;
+ CHAR y_dc_delta_q;
+ CHAR u_dc_delta_q;
+ CHAR v_dc_delta_q;
+ CHAR u_ac_delta_q;
+ CHAR v_ac_delta_q;
+ // using_qmatrix:
+ UCHAR qm_y;
+ UCHAR qm_u;
+ UCHAR qm_v;
+ UINT16 Reserved16Bits;
+ } quantization;
+
+ // Cdef parameters
+ struct {
+ union {
+ struct {
+ UCHAR damping : 2;
+ UCHAR bits : 2;
+ UCHAR Reserved : 4;
+ };
+ UCHAR ControlFlags;
+ } DUMMYUNIONNAME;
+
+ union {
+ struct {
+ UCHAR primary : 6;
+ UCHAR secondary : 2;
+ };
+ UCHAR combined;
+ } y_strengths[8];
+
+ union {
+ struct {
+ UCHAR primary : 6;
+ UCHAR secondary : 2;
+ };
+ UCHAR combined;
+ } uv_strengths[8];
+
+ } cdef;
+
+ UCHAR interp_filter;
+
+ // Segmentation
+ struct {
+ union {
+ struct {
+ UCHAR enabled : 1;
+ UCHAR update_map : 1;
+ UCHAR update_data : 1;
+ UCHAR temporal_update : 1;
+ UCHAR Reserved : 4;
+ };
+ UCHAR ControlFlags;
+ } DUMMYUNIONNAME;
+ UCHAR Reserved24Bits[3];
+
+ union {
+ struct {
+ UCHAR alt_q : 1;
+ UCHAR alt_lf_y_v : 1;
+ UCHAR alt_lf_y_h : 1;
+ UCHAR alt_lf_u : 1;
+ UCHAR alt_lf_v : 1;
+ UCHAR ref_frame : 1;
+ UCHAR skip : 1;
+ UCHAR globalmv : 1;
+ };
+ UCHAR mask;
+ } feature_mask[8];
+
+ SHORT feature_data[8][8];
+
+ } segmentation;
+
+ struct {
+ union {
+ struct {
+ USHORT apply_grain : 1;
+ USHORT scaling_shift_minus8 : 2;
+ USHORT chroma_scaling_from_luma : 1;
+ USHORT ar_coeff_lag : 2;
+ USHORT ar_coeff_shift_minus6 : 2;
+ USHORT grain_scale_shift : 2;
+ USHORT overlap_flag : 1;
+ USHORT clip_to_restricted_range : 1;
+ USHORT matrix_coeff_is_identity : 1;
+ USHORT Reserved : 3;
+ };
+ USHORT ControlFlags;
+ } DUMMYUNIONNAME;
+
+ USHORT grain_seed;
+ UCHAR scaling_points_y[14][2];
+ UCHAR num_y_points;
+ UCHAR scaling_points_cb[10][2];
+ UCHAR num_cb_points;
+ UCHAR scaling_points_cr[10][2];
+ UCHAR num_cr_points;
+ UCHAR ar_coeffs_y[24];
+ UCHAR ar_coeffs_cb[25];
+ UCHAR ar_coeffs_cr[25];
+ UCHAR cb_mult;
+ UCHAR cb_luma_mult;
+ UCHAR cr_mult;
+ UCHAR cr_luma_mult;
+ UCHAR Reserved8Bits;
+ SHORT cb_offset;
+ SHORT cr_offset;
+ } film_grain;
+
+ UINT Reserved32Bits;
+ UINT StatusReportFeedbackNumber;
+} DXVA_PicParams_AV1, *LPDXVA_PicParams_AV1;
+
+/* AV1 tile data structure */
+typedef struct _DXVA_Tile_AV1 {
+ UINT DataOffset;
+ UINT DataSize;
+ USHORT row;
+ USHORT column;
+ USHORT Reserved16Bits;
+ UCHAR anchor_frame;
+ UCHAR Reserved8Bits;
+} DXVA_Tile_AV1, *LPDXVA_Tile_AV1;
+
+typedef struct _DXVA_Status_AV1 {
+ UINT StatusReportFeedbackNumber;
+ DXVA_PicEntry_AV1 CurrPic;
+ UCHAR bBufType;
+ UCHAR bStatus;
+ UCHAR bReserved8Bits;
+ USHORT wNumMbsAffected;
+} DXVA_Status_AV1, *LPDXVA_Status_AV1;
+
#include <poppack.h>
typedef enum _DXVA_VideoChromaSubsampling
--
2.26.2
4
7
12 Jul '21
We tag far fewer symbols this way.
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
configure.ac | 1 +
include/private/vkd3d_common.h | 6 +
include/private/vkd3d_debug.h | 19 ++-
include/private/vkd3d_memory.h | 3 +-
include/private/vkd3d_utf8.h | 2 +-
libs/vkd3d-common/debug.c | 2 +-
libs/vkd3d-shader/dxbc.c | 6 +-
libs/vkd3d-shader/vkd3d_shader_main.c | 24 +--
libs/vkd3d-shader/vkd3d_shader_private.h | 48 +++---
libs/vkd3d-utils/vkd3d_utils_main.c | 22 +--
libs/vkd3d/command.c | 6 +-
libs/vkd3d/device.c | 16 +-
libs/vkd3d/resource.c | 6 +-
libs/vkd3d/utils.c | 4 +-
libs/vkd3d/vkd3d_main.c | 10 +-
libs/vkd3d/vkd3d_private.h | 188 +++++++++++------------
16 files changed, 184 insertions(+), 179 deletions(-)
diff --git a/configure.ac b/configure.ac
index d5f6588..e9c135a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,6 +47,7 @@ AC_SUBST([VKD3D_CFLAGS])
AS_IF([test "x${GCC}" = "xyes"],
[VKD3D_CFLAGS="-Wall -pipe"
VKD3D_CHECK_CFLAGS([-std=c99])
+ VKD3D_CHECK_CFLAGS([-fvisibility=hidden])
VKD3D_CHECK_CFLAGS([-Wdeclaration-after-statement])
VKD3D_CHECK_CFLAGS([-Wimplicit-fallthrough])
VKD3D_CHECK_CFLAGS([-Wmissing-prototypes])
diff --git a/include/private/vkd3d_common.h b/include/private/vkd3d_common.h
index ac217e9..fd62ae8 100644
--- a/include/private/vkd3d_common.h
+++ b/include/private/vkd3d_common.h
@@ -53,6 +53,12 @@ static inline size_t align(size_t addr, size_t alignment)
# define VKD3D_UNUSED
#endif /* __GNUC__ */
+#if defined(__GNUC__) && !defined(__MINGW32__)
+# define VKD3D_API __attribute__((visibility("default")))
+#else
+# define VKD3D_API
+#endif
+
static inline unsigned int vkd3d_popcount(unsigned int v)
{
#ifdef _MSC_VER
diff --git a/include/private/vkd3d_debug.h b/include/private/vkd3d_debug.h
index c37c841..a206a92 100644
--- a/include/private/vkd3d_debug.h
+++ b/include/private/vkd3d_debug.h
@@ -44,15 +44,14 @@ enum vkd3d_dbg_level
VKD3D_DBG_LEVEL_TRACE,
};
-enum vkd3d_dbg_level vkd3d_dbg_get_level(void) DECLSPEC_HIDDEN;
+enum vkd3d_dbg_level vkd3d_dbg_get_level(void);
-void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function,
- const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4) DECLSPEC_HIDDEN;
+void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4);
-const char *vkd3d_dbg_sprintf(const char *fmt, ...) VKD3D_PRINTF_FUNC(1, 2) DECLSPEC_HIDDEN;
-const char *vkd3d_dbg_vsprintf(const char *fmt, va_list args) DECLSPEC_HIDDEN;
-const char *debugstr_a(const char *str) DECLSPEC_HIDDEN;
-const char *debugstr_w(const WCHAR *wstr, size_t wchar_size) DECLSPEC_HIDDEN;
+const char *vkd3d_dbg_sprintf(const char *fmt, ...) VKD3D_PRINTF_FUNC(1, 2);
+const char *vkd3d_dbg_vsprintf(const char *fmt, va_list args);
+const char *debugstr_a(const char *str);
+const char *debugstr_w(const WCHAR *wstr, size_t wchar_size);
#define VKD3D_DBG_LOG(level) \
do { \
@@ -103,7 +102,7 @@ static inline const char *debugstr_guid(const GUID *guid)
guid->Data4[5], guid->Data4[6], guid->Data4[7]);
}
-unsigned int vkd3d_env_var_as_uint(const char *name, unsigned int default_value) DECLSPEC_HIDDEN;
+unsigned int vkd3d_env_var_as_uint(const char *name, unsigned int default_value);
struct vkd3d_debug_option
{
@@ -111,8 +110,8 @@ struct vkd3d_debug_option
uint64_t flag;
};
-bool vkd3d_debug_list_has_member(const char *string, const char *member) DECLSPEC_HIDDEN;
+bool vkd3d_debug_list_has_member(const char *string, const char *member);
uint64_t vkd3d_parse_debug_options(const char *string,
- const struct vkd3d_debug_option *options, unsigned int option_count) DECLSPEC_HIDDEN;
+ const struct vkd3d_debug_option *options, unsigned int option_count);
#endif /* __VKD3D_DEBUG_H */
diff --git a/include/private/vkd3d_memory.h b/include/private/vkd3d_memory.h
index df93abf..8bbc691 100644
--- a/include/private/vkd3d_memory.h
+++ b/include/private/vkd3d_memory.h
@@ -54,7 +54,6 @@ static inline void vkd3d_free(void *ptr)
free(ptr);
}
-bool vkd3d_array_reserve(void **elements, size_t *capacity,
- size_t element_count, size_t element_size) DECLSPEC_HIDDEN;
+bool vkd3d_array_reserve(void **elements, size_t *capacity, size_t element_count, size_t element_size);
#endif /* __VKD3D_MEMORY_H */
diff --git a/include/private/vkd3d_utf8.h b/include/private/vkd3d_utf8.h
index ab32884..ccb9e17 100644
--- a/include/private/vkd3d_utf8.h
+++ b/include/private/vkd3d_utf8.h
@@ -21,6 +21,6 @@
#include "vkd3d_common.h"
-char *vkd3d_strdup_w_utf8(const WCHAR *wstr, size_t wchar_size) DECLSPEC_HIDDEN;
+char *vkd3d_strdup_w_utf8(const WCHAR *wstr, size_t wchar_size);
#endif /* __VKD3D_UTF8_H */
diff --git a/libs/vkd3d-common/debug.c b/libs/vkd3d-common/debug.c
index 33deed6..a4d5a3d 100644
--- a/libs/vkd3d-common/debug.c
+++ b/libs/vkd3d-common/debug.c
@@ -31,7 +31,7 @@
#define VKD3D_DEBUG_BUFFER_COUNT 64
#define VKD3D_DEBUG_BUFFER_SIZE 512
-extern const char *vkd3d_dbg_env_name DECLSPEC_HIDDEN;
+extern const char *vkd3d_dbg_env_name;
static const char *debug_level_names[] =
{
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c
index 973a80d..231c48b 100644
--- a/libs/vkd3d-shader/dxbc.c
+++ b/libs/vkd3d-shader/dxbc.c
@@ -2726,7 +2726,7 @@ static int rts0_handler(const char *data, DWORD data_size, DWORD tag, void *cont
return shader_parse_root_signature(data, data_size, desc);
}
-int vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc,
+VKD3D_API int vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc,
struct vkd3d_shader_versioned_root_signature_desc *root_signature, char **messages)
{
struct vkd3d_shader_message_context message_context;
@@ -3288,7 +3288,7 @@ static int validate_root_signature_desc(const struct vkd3d_shader_versioned_root
return ret;
}
-int vkd3d_shader_serialize_root_signature(const struct vkd3d_shader_versioned_root_signature_desc *root_signature,
+VKD3D_API int vkd3d_shader_serialize_root_signature(const struct vkd3d_shader_versioned_root_signature_desc *root_signature,
struct vkd3d_shader_code *dxbc, char **messages)
{
struct root_signature_writer_context context;
@@ -3592,7 +3592,7 @@ fail:
return ret;
}
-int vkd3d_shader_convert_root_signature(struct vkd3d_shader_versioned_root_signature_desc *dst,
+VKD3D_API int vkd3d_shader_convert_root_signature(struct vkd3d_shader_versioned_root_signature_desc *dst,
enum vkd3d_shader_root_signature_version version, const struct vkd3d_shader_versioned_root_signature_desc *src)
{
int ret;
diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c
index 16d895f..4d49eef 100644
--- a/libs/vkd3d-shader/vkd3d_shader_main.c
+++ b/libs/vkd3d-shader/vkd3d_shader_main.c
@@ -292,14 +292,14 @@ static int vkd3d_shader_validate_compile_info(const struct vkd3d_shader_compile_
return VKD3D_OK;
}
-void vkd3d_shader_free_messages(char *messages)
+VKD3D_API void vkd3d_shader_free_messages(char *messages)
{
TRACE("messages %p.\n", messages);
vkd3d_free(messages);
}
-int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info,
+VKD3D_API int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info,
struct vkd3d_shader_code *out, char **messages)
{
struct vkd3d_shader_scan_descriptor_info scan_descriptor_info;
@@ -837,7 +837,7 @@ static int vkd3d_shader_scan_instruction(struct vkd3d_shader_scan_context *conte
return VKD3D_OK;
}
-int vkd3d_shader_scan(const struct vkd3d_shader_compile_info *compile_info, char **messages)
+VKD3D_API int vkd3d_shader_scan(const struct vkd3d_shader_compile_info *compile_info, char **messages)
{
struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info;
struct vkd3d_shader_message_context *message_context;
@@ -912,14 +912,14 @@ done:
return ret;
}
-void vkd3d_shader_free_scan_descriptor_info(struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info)
+VKD3D_API void vkd3d_shader_free_scan_descriptor_info(struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info)
{
TRACE("scan_descriptor_info %p.\n", scan_descriptor_info);
vkd3d_free(scan_descriptor_info->descriptors);
}
-void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *shader_code)
+VKD3D_API void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *shader_code)
{
TRACE("shader_code %p.\n", shader_code);
@@ -960,7 +960,7 @@ static void vkd3d_shader_free_root_signature_v_1_1(struct vkd3d_shader_root_sign
memset(root_signature, 0, sizeof(*root_signature));
}
-void vkd3d_shader_free_root_signature(struct vkd3d_shader_versioned_root_signature_desc *desc)
+VKD3D_API void vkd3d_shader_free_root_signature(struct vkd3d_shader_versioned_root_signature_desc *desc)
{
TRACE("desc %p.\n", desc);
@@ -981,7 +981,7 @@ void vkd3d_shader_free_root_signature(struct vkd3d_shader_versioned_root_signatu
desc->version = 0;
}
-int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc,
+VKD3D_API int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc,
struct vkd3d_shader_signature *signature, char **messages)
{
struct vkd3d_shader_message_context message_context;
@@ -1004,7 +1004,7 @@ int vkd3d_shader_parse_input_signature(const struct vkd3d_shader_code *dxbc,
return ret;
}
-struct vkd3d_shader_signature_element *vkd3d_shader_find_signature_element(
+VKD3D_API struct vkd3d_shader_signature_element *vkd3d_shader_find_signature_element(
const struct vkd3d_shader_signature *signature, const char *semantic_name,
unsigned int semantic_index, unsigned int stream_index)
{
@@ -1026,7 +1026,7 @@ struct vkd3d_shader_signature_element *vkd3d_shader_find_signature_element(
return NULL;
}
-void vkd3d_shader_free_shader_signature(struct vkd3d_shader_signature *signature)
+VKD3D_API void vkd3d_shader_free_shader_signature(struct vkd3d_shader_signature *signature)
{
TRACE("signature %p.\n", signature);
@@ -1034,7 +1034,7 @@ void vkd3d_shader_free_shader_signature(struct vkd3d_shader_signature *signature
signature->elements = NULL;
}
-const char *vkd3d_shader_get_version(unsigned int *major, unsigned int *minor)
+VKD3D_API const char *vkd3d_shader_get_version(unsigned int *major, unsigned int *minor)
{
int x, y;
@@ -1052,7 +1052,7 @@ const char *vkd3d_shader_get_version(unsigned int *major, unsigned int *minor)
return "vkd3d-shader " PACKAGE_VERSION VKD3D_VCS_ID;
}
-const enum vkd3d_shader_source_type *vkd3d_shader_get_supported_source_types(unsigned int *count)
+VKD3D_API const enum vkd3d_shader_source_type *vkd3d_shader_get_supported_source_types(unsigned int *count)
{
static const enum vkd3d_shader_source_type types[] =
{
@@ -1065,7 +1065,7 @@ const enum vkd3d_shader_source_type *vkd3d_shader_get_supported_source_types(uns
return types;
}
-const enum vkd3d_shader_target_type *vkd3d_shader_get_supported_target_types(
+VKD3D_API const enum vkd3d_shader_target_type *vkd3d_shader_get_supported_target_types(
enum vkd3d_shader_source_type source_type, unsigned int *count)
{
static const enum vkd3d_shader_target_type dxbc_tpf_types[] =
diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h
index 1acb01f..1291148 100644
--- a/libs/vkd3d-shader/vkd3d_shader_private.h
+++ b/libs/vkd3d-shader/vkd3d_shader_private.h
@@ -809,18 +809,18 @@ static inline bool vkd3d_shader_register_is_output(const struct vkd3d_shader_reg
return reg->type == VKD3DSPR_OUTPUT || reg->type == VKD3DSPR_COLOROUT;
}
-void vkd3d_shader_trace(void *data) DECLSPEC_HIDDEN;
+void vkd3d_shader_trace(void *data);
-const char *shader_get_type_prefix(enum vkd3d_shader_type type) DECLSPEC_HIDDEN;
+const char *shader_get_type_prefix(enum vkd3d_shader_type type);
void *shader_sm4_init(const DWORD *byte_code, size_t byte_code_size,
- const struct vkd3d_shader_signature *output_signature) DECLSPEC_HIDDEN;
-void shader_sm4_free(void *data) DECLSPEC_HIDDEN;
+ const struct vkd3d_shader_signature *output_signature);
+void shader_sm4_free(void *data);
void shader_sm4_read_header(void *data, const DWORD **ptr,
- struct vkd3d_shader_version *shader_version) DECLSPEC_HIDDEN;
+ struct vkd3d_shader_version *shader_version);
void shader_sm4_read_instruction(void *data, const DWORD **ptr,
- struct vkd3d_shader_instruction *ins) DECLSPEC_HIDDEN;
-bool shader_sm4_is_end(void *data, const DWORD **ptr) DECLSPEC_HIDDEN;
+ struct vkd3d_shader_instruction *ins);
+bool shader_sm4_is_end(void *data, const DWORD **ptr);
struct vkd3d_string_buffer
{
@@ -829,9 +829,9 @@ struct vkd3d_string_buffer
unsigned int content_size;
};
-void vkd3d_string_buffer_cleanup(struct vkd3d_string_buffer *buffer) DECLSPEC_HIDDEN;
-bool vkd3d_string_buffer_init(struct vkd3d_string_buffer *buffer) DECLSPEC_HIDDEN;
-int vkd3d_string_buffer_vprintf(struct vkd3d_string_buffer *buffer, const char *format, va_list args) DECLSPEC_HIDDEN;
+void vkd3d_string_buffer_cleanup(struct vkd3d_string_buffer *buffer);
+bool vkd3d_string_buffer_init(struct vkd3d_string_buffer *buffer);
+int vkd3d_string_buffer_vprintf(struct vkd3d_string_buffer *buffer, const char *format, va_list args);
struct vkd3d_shader_message_context
{
@@ -841,39 +841,39 @@ struct vkd3d_shader_message_context
struct vkd3d_string_buffer messages;
};
-void vkd3d_shader_message_context_cleanup(struct vkd3d_shader_message_context *context) DECLSPEC_HIDDEN;
-char *vkd3d_shader_message_context_copy_messages(struct vkd3d_shader_message_context *context) DECLSPEC_HIDDEN;
+void vkd3d_shader_message_context_cleanup(struct vkd3d_shader_message_context *context);
+char *vkd3d_shader_message_context_copy_messages(struct vkd3d_shader_message_context *context);
bool vkd3d_shader_message_context_init(struct vkd3d_shader_message_context *context,
- enum vkd3d_shader_log_level log_level, const char *source_name) DECLSPEC_HIDDEN;
+ enum vkd3d_shader_log_level log_level, const char *source_name);
void vkd3d_shader_message_context_trace_messages_(const struct vkd3d_shader_message_context *context,
- const char *function) DECLSPEC_HIDDEN;
+ const char *function);
#define vkd3d_shader_message_context_trace_messages(context) \
vkd3d_shader_message_context_trace_messages_(context, __FUNCTION__)
void vkd3d_shader_error(struct vkd3d_shader_message_context *context, enum vkd3d_shader_error error,
- const char *format, ...) VKD3D_PRINTF_FUNC(3, 4) DECLSPEC_HIDDEN;
+ const char *format, ...) VKD3D_PRINTF_FUNC(3, 4);
void vkd3d_shader_verror(struct vkd3d_shader_message_context *context,
- enum vkd3d_shader_error error, const char *format, va_list args) DECLSPEC_HIDDEN;
+ enum vkd3d_shader_error error, const char *format, va_list args);
int shader_extract_from_dxbc(const void *dxbc, size_t dxbc_length,
- struct vkd3d_shader_message_context *message_context, struct vkd3d_shader_desc *desc) DECLSPEC_HIDDEN;
-void free_shader_desc(struct vkd3d_shader_desc *desc) DECLSPEC_HIDDEN;
+ struct vkd3d_shader_message_context *message_context, struct vkd3d_shader_desc *desc);
+void free_shader_desc(struct vkd3d_shader_desc *desc);
int shader_parse_input_signature(const void *dxbc, size_t dxbc_length,
- struct vkd3d_shader_message_context *message_context, struct vkd3d_shader_signature *signature) DECLSPEC_HIDDEN;
+ struct vkd3d_shader_message_context *message_context, struct vkd3d_shader_signature *signature);
struct vkd3d_dxbc_compiler;
struct vkd3d_dxbc_compiler *vkd3d_dxbc_compiler_create(const struct vkd3d_shader_version *shader_version,
const struct vkd3d_shader_desc *shader_desc, const struct vkd3d_shader_compile_info *compile_info,
const struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info,
- struct vkd3d_shader_message_context *message_context) DECLSPEC_HIDDEN;
+ struct vkd3d_shader_message_context *message_context);
int vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler,
- const struct vkd3d_shader_instruction *instruction) DECLSPEC_HIDDEN;
+ const struct vkd3d_shader_instruction *instruction);
int vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler,
- const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *spirv) DECLSPEC_HIDDEN;
-void vkd3d_dxbc_compiler_destroy(struct vkd3d_dxbc_compiler *compiler) DECLSPEC_HIDDEN;
+ const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *spirv);
+void vkd3d_dxbc_compiler_destroy(struct vkd3d_dxbc_compiler *compiler);
-void vkd3d_compute_dxbc_checksum(const void *dxbc, size_t size, uint32_t checksum[4]) DECLSPEC_HIDDEN;
+void vkd3d_compute_dxbc_checksum(const void *dxbc, size_t size, uint32_t checksum[4]);
static inline enum vkd3d_shader_component_type vkd3d_component_type_from_data_type(
enum vkd3d_data_type data_type)
diff --git a/libs/vkd3d-utils/vkd3d_utils_main.c b/libs/vkd3d-utils/vkd3d_utils_main.c
index c19fe7f..b64693e 100644
--- a/libs/vkd3d-utils/vkd3d_utils_main.c
+++ b/libs/vkd3d-utils/vkd3d_utils_main.c
@@ -21,14 +21,14 @@
VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG");
-HRESULT WINAPI D3D12GetDebugInterface(REFIID iid, void **debug)
+VKD3D_API HRESULT WINAPI D3D12GetDebugInterface(REFIID iid, void **debug)
{
FIXME("iid %s, debug %p stub!\n", debugstr_guid(iid), debug);
return E_NOTIMPL;
}
-HRESULT WINAPI D3D12CreateDeviceVKD3D(IUnknown *adapter, D3D_FEATURE_LEVEL minimum_feature_level,
+VKD3D_API HRESULT WINAPI D3D12CreateDeviceVKD3D(IUnknown *adapter, D3D_FEATURE_LEVEL minimum_feature_level,
REFIID iid, void **device, enum vkd3d_api_version api_version)
{
struct vkd3d_optional_instance_extensions_info optional_extensions_info;
@@ -85,13 +85,13 @@ HRESULT WINAPI D3D12CreateDeviceVKD3D(IUnknown *adapter, D3D_FEATURE_LEVEL minim
return vkd3d_create_device(&device_create_info, iid, device);
}
-HRESULT WINAPI D3D12CreateDevice(IUnknown *adapter,
+VKD3D_API HRESULT WINAPI D3D12CreateDevice(IUnknown *adapter,
D3D_FEATURE_LEVEL minimum_feature_level, REFIID iid, void **device)
{
return D3D12CreateDeviceVKD3D(adapter, minimum_feature_level, iid, device, VKD3D_API_VERSION_1_0);
}
-HRESULT WINAPI D3D12CreateRootSignatureDeserializer(const void *data, SIZE_T data_size,
+VKD3D_API HRESULT WINAPI D3D12CreateRootSignatureDeserializer(const void *data, SIZE_T data_size,
REFIID iid, void **deserializer)
{
TRACE("data %p, data_size %lu, iid %s, deserializer %p.\n",
@@ -100,7 +100,7 @@ HRESULT WINAPI D3D12CreateRootSignatureDeserializer(const void *data, SIZE_T dat
return vkd3d_create_root_signature_deserializer(data, data_size, iid, deserializer);
}
-HRESULT WINAPI D3D12CreateVersionedRootSignatureDeserializer(const void *data, SIZE_T data_size,
+VKD3D_API HRESULT WINAPI D3D12CreateVersionedRootSignatureDeserializer(const void *data, SIZE_T data_size,
REFIID iid,void **deserializer)
{
TRACE("data %p, data_size %lu, iid %s, deserializer %p.\n",
@@ -109,7 +109,7 @@ HRESULT WINAPI D3D12CreateVersionedRootSignatureDeserializer(const void *data, S
return vkd3d_create_versioned_root_signature_deserializer(data, data_size, iid, deserializer);
}
-HRESULT WINAPI D3D12SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC *desc,
+VKD3D_API HRESULT WINAPI D3D12SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC *desc,
D3D_ROOT_SIGNATURE_VERSION version, ID3DBlob **blob, ID3DBlob **error_blob)
{
TRACE("desc %p, version %#x, blob %p, error_blob %p.\n", desc, version, blob, error_blob);
@@ -117,7 +117,7 @@ HRESULT WINAPI D3D12SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC *desc
return vkd3d_serialize_root_signature(desc, version, blob, error_blob);
}
-HRESULT WINAPI D3D12SerializeVersionedRootSignature(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *desc,
+VKD3D_API HRESULT WINAPI D3D12SerializeVersionedRootSignature(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *desc,
ID3DBlob **blob, ID3DBlob **error_blob)
{
TRACE("desc %p, blob %p, error_blob %p.\n", desc, blob, error_blob);
@@ -126,7 +126,7 @@ HRESULT WINAPI D3D12SerializeVersionedRootSignature(const D3D12_VERSIONED_ROOT_S
}
/* Events */
-HANDLE vkd3d_create_event(void)
+VKD3D_API HANDLE vkd3d_create_event(void)
{
struct vkd3d_event *event;
int rc;
@@ -157,7 +157,7 @@ HANDLE vkd3d_create_event(void)
return event;
}
-unsigned int vkd3d_wait_event(HANDLE event, unsigned int milliseconds)
+VKD3D_API unsigned int vkd3d_wait_event(HANDLE event, unsigned int milliseconds)
{
struct vkd3d_event *impl = event;
int rc;
@@ -200,7 +200,7 @@ unsigned int vkd3d_wait_event(HANDLE event, unsigned int milliseconds)
return VKD3D_WAIT_FAILED;
}
-HRESULT vkd3d_signal_event(HANDLE event)
+VKD3D_API HRESULT vkd3d_signal_event(HANDLE event)
{
struct vkd3d_event *impl = event;
int rc;
@@ -219,7 +219,7 @@ HRESULT vkd3d_signal_event(HANDLE event)
return S_OK;
}
-void vkd3d_destroy_event(HANDLE event)
+VKD3D_API void vkd3d_destroy_event(HANDLE event)
{
struct vkd3d_event *impl = event;
int rc;
diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c
index e5c6791..4ff510a 100644
--- a/libs/vkd3d/command.c
+++ b/libs/vkd3d/command.c
@@ -6251,21 +6251,21 @@ HRESULT d3d12_command_queue_create(struct d3d12_device *device,
return S_OK;
}
-uint32_t vkd3d_get_vk_queue_family_index(ID3D12CommandQueue *queue)
+VKD3D_API uint32_t vkd3d_get_vk_queue_family_index(ID3D12CommandQueue *queue)
{
struct d3d12_command_queue *d3d12_queue = impl_from_ID3D12CommandQueue(queue);
return d3d12_queue->vkd3d_queue->vk_family_index;
}
-VkQueue vkd3d_acquire_vk_queue(ID3D12CommandQueue *queue)
+VKD3D_API VkQueue vkd3d_acquire_vk_queue(ID3D12CommandQueue *queue)
{
struct d3d12_command_queue *d3d12_queue = impl_from_ID3D12CommandQueue(queue);
return vkd3d_queue_acquire(d3d12_queue->vkd3d_queue);
}
-void vkd3d_release_vk_queue(ID3D12CommandQueue *queue)
+VKD3D_API void vkd3d_release_vk_queue(ID3D12CommandQueue *queue)
{
struct d3d12_command_queue *d3d12_queue = impl_from_ID3D12CommandQueue(queue);
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index bef6477..38d3d56 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -589,7 +589,7 @@ static HRESULT vkd3d_instance_init(struct vkd3d_instance *instance,
return S_OK;
}
-HRESULT vkd3d_create_instance(const struct vkd3d_instance_create_info *create_info,
+VKD3D_API HRESULT vkd3d_create_instance(const struct vkd3d_instance_create_info *create_info,
struct vkd3d_instance **instance)
{
struct vkd3d_instance *object;
@@ -637,7 +637,7 @@ static void vkd3d_destroy_instance(struct vkd3d_instance *instance)
vkd3d_free(instance);
}
-ULONG vkd3d_instance_incref(struct vkd3d_instance *instance)
+VKD3D_API ULONG vkd3d_instance_incref(struct vkd3d_instance *instance)
{
ULONG refcount = InterlockedIncrement(&instance->refcount);
@@ -646,7 +646,7 @@ ULONG vkd3d_instance_incref(struct vkd3d_instance *instance)
return refcount;
}
-ULONG vkd3d_instance_decref(struct vkd3d_instance *instance)
+VKD3D_API ULONG vkd3d_instance_decref(struct vkd3d_instance *instance)
{
ULONG refcount = InterlockedDecrement(&instance->refcount);
@@ -658,7 +658,7 @@ ULONG vkd3d_instance_decref(struct vkd3d_instance *instance)
return refcount;
}
-VkInstance vkd3d_instance_get_vk_instance(struct vkd3d_instance *instance)
+VKD3D_API VkInstance vkd3d_instance_get_vk_instance(struct vkd3d_instance *instance)
{
return instance->vk_instance;
}
@@ -3828,28 +3828,28 @@ HRESULT vkd3d_join_thread(struct vkd3d_instance *instance, union vkd3d_thread_ha
return hr;
}
-IUnknown *vkd3d_get_device_parent(ID3D12Device *device)
+VKD3D_API IUnknown *vkd3d_get_device_parent(ID3D12Device *device)
{
struct d3d12_device *d3d12_device = impl_from_ID3D12Device(device);
return d3d12_device->parent;
}
-VkDevice vkd3d_get_vk_device(ID3D12Device *device)
+VKD3D_API VkDevice vkd3d_get_vk_device(ID3D12Device *device)
{
struct d3d12_device *d3d12_device = impl_from_ID3D12Device(device);
return d3d12_device->vk_device;
}
-VkPhysicalDevice vkd3d_get_vk_physical_device(ID3D12Device *device)
+VKD3D_API VkPhysicalDevice vkd3d_get_vk_physical_device(ID3D12Device *device)
{
struct d3d12_device *d3d12_device = impl_from_ID3D12Device(device);
return d3d12_device->vk_physical_device;
}
-struct vkd3d_instance *vkd3d_instance_from_device(ID3D12Device *device)
+VKD3D_API struct vkd3d_instance *vkd3d_instance_from_device(ID3D12Device *device)
{
struct d3d12_device *d3d12_device = impl_from_ID3D12Device(device);
diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c
index a9d4d46..a432806 100644
--- a/libs/vkd3d/resource.c
+++ b/libs/vkd3d/resource.c
@@ -1983,7 +1983,7 @@ HRESULT d3d12_reserved_resource_create(struct d3d12_device *device,
return S_OK;
}
-HRESULT vkd3d_create_image_resource(ID3D12Device *device,
+VKD3D_API HRESULT vkd3d_create_image_resource(ID3D12Device *device,
const struct vkd3d_image_resource_create_info *create_info, ID3D12Resource **resource)
{
struct d3d12_device *d3d12_device = unsafe_impl_from_ID3D12Device(device);
@@ -2035,13 +2035,13 @@ HRESULT vkd3d_create_image_resource(ID3D12Device *device,
return S_OK;
}
-ULONG vkd3d_resource_incref(ID3D12Resource *resource)
+VKD3D_API ULONG vkd3d_resource_incref(ID3D12Resource *resource)
{
TRACE("resource %p.\n", resource);
return d3d12_resource_incref(impl_from_ID3D12Resource(resource));
}
-ULONG vkd3d_resource_decref(ID3D12Resource *resource)
+VKD3D_API ULONG vkd3d_resource_decref(ID3D12Resource *resource)
{
TRACE("resource %p.\n", resource);
return d3d12_resource_decref(impl_from_ID3D12Resource(resource));
diff --git a/libs/vkd3d/utils.c b/libs/vkd3d/utils.c
index 7abfd42..ea11f3a 100644
--- a/libs/vkd3d/utils.c
+++ b/libs/vkd3d/utils.c
@@ -506,7 +506,7 @@ void vkd3d_format_copy_data(const struct vkd3d_format *format, const uint8_t *sr
}
}
-VkFormat vkd3d_get_vk_format(DXGI_FORMAT format)
+VKD3D_API VkFormat vkd3d_get_vk_format(DXGI_FORMAT format)
{
const struct vkd3d_format *vkd3d_format;
@@ -516,7 +516,7 @@ VkFormat vkd3d_get_vk_format(DXGI_FORMAT format)
return vkd3d_format->vk_format;
}
-DXGI_FORMAT vkd3d_get_dxgi_format(VkFormat format)
+VKD3D_API DXGI_FORMAT vkd3d_get_dxgi_format(VkFormat format)
{
DXGI_FORMAT dxgi_format;
VkFormat vk_format;
diff --git a/libs/vkd3d/vkd3d_main.c b/libs/vkd3d/vkd3d_main.c
index 327cdf8..4c0d6c5 100644
--- a/libs/vkd3d/vkd3d_main.c
+++ b/libs/vkd3d/vkd3d_main.c
@@ -21,7 +21,7 @@
VKD3D_DEBUG_ENV_NAME("VKD3D_DEBUG");
-HRESULT vkd3d_create_device(const struct vkd3d_device_create_info *create_info,
+VKD3D_API HRESULT vkd3d_create_device(const struct vkd3d_device_create_info *create_info,
REFIID iid, void **device)
{
struct vkd3d_instance *instance;
@@ -216,7 +216,7 @@ static HRESULT d3d12_root_signature_deserializer_init(struct d3d12_root_signatur
return S_OK;
}
-HRESULT vkd3d_create_root_signature_deserializer(const void *data, SIZE_T data_size,
+VKD3D_API HRESULT vkd3d_create_root_signature_deserializer(const void *data, SIZE_T data_size,
REFIID iid, void **deserializer)
{
struct vkd3d_shader_code dxbc = {data, data_size};
@@ -400,7 +400,7 @@ static HRESULT d3d12_versioned_root_signature_deserializer_init(struct d3d12_ver
return S_OK;
}
-HRESULT vkd3d_create_versioned_root_signature_deserializer(const void *data, SIZE_T data_size,
+VKD3D_API HRESULT vkd3d_create_versioned_root_signature_deserializer(const void *data, SIZE_T data_size,
REFIID iid, void **deserializer)
{
struct d3d12_versioned_root_signature_deserializer *object;
@@ -537,7 +537,7 @@ static HRESULT d3d_blob_create(void *buffer, SIZE_T size, struct d3d_blob **blob
return S_OK;
}
-HRESULT vkd3d_serialize_root_signature(const D3D12_ROOT_SIGNATURE_DESC *desc,
+VKD3D_API HRESULT vkd3d_serialize_root_signature(const D3D12_ROOT_SIGNATURE_DESC *desc,
D3D_ROOT_SIGNATURE_VERSION version, ID3DBlob **blob, ID3DBlob **error_blob)
{
struct vkd3d_shader_versioned_root_signature_desc vkd3d_desc;
@@ -592,7 +592,7 @@ HRESULT vkd3d_serialize_root_signature(const D3D12_ROOT_SIGNATURE_DESC *desc,
return S_OK;
}
-HRESULT vkd3d_serialize_versioned_root_signature(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *desc,
+VKD3D_API HRESULT vkd3d_serialize_versioned_root_signature(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *desc,
ID3DBlob **blob, ID3DBlob **error_blob)
{
const struct vkd3d_shader_versioned_root_signature_desc *vkd3d_desc;
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index 9f0982d..54077f9 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -82,9 +82,9 @@ struct vkd3d_vk_device_procs
};
#undef DECLARE_VK_PFN
-HRESULT hresult_from_errno(int rc) DECLSPEC_HIDDEN;
-HRESULT hresult_from_vk_result(VkResult vr) DECLSPEC_HIDDEN;
-HRESULT hresult_from_vkd3d_result(int vkd3d_result) DECLSPEC_HIDDEN;
+HRESULT hresult_from_errno(int rc);
+HRESULT hresult_from_vk_result(VkResult vr);
+HRESULT hresult_from_vkd3d_result(int vkd3d_result);
struct vkd3d_vulkan_info
{
@@ -161,8 +161,8 @@ union vkd3d_thread_handle
};
HRESULT vkd3d_create_thread(struct vkd3d_instance *instance,
- PFN_vkd3d_thread thread_main, void *data, union vkd3d_thread_handle *thread) DECLSPEC_HIDDEN;
-HRESULT vkd3d_join_thread(struct vkd3d_instance *instance, union vkd3d_thread_handle *thread) DECLSPEC_HIDDEN;
+ PFN_vkd3d_thread thread_main, void *data, union vkd3d_thread_handle *thread);
+HRESULT vkd3d_join_thread(struct vkd3d_instance *instance, union vkd3d_thread_handle *thread);
struct vkd3d_waiting_fence
{
@@ -199,9 +199,9 @@ struct vkd3d_fence_worker
};
HRESULT vkd3d_fence_worker_start(struct vkd3d_fence_worker *worker,
- struct d3d12_device *device) DECLSPEC_HIDDEN;
+ struct d3d12_device *device);
HRESULT vkd3d_fence_worker_stop(struct vkd3d_fence_worker *worker,
- struct d3d12_device *device) DECLSPEC_HIDDEN;
+ struct d3d12_device *device);
struct vkd3d_gpu_va_allocation
{
@@ -230,11 +230,11 @@ struct vkd3d_gpu_va_allocator
};
D3D12_GPU_VIRTUAL_ADDRESS vkd3d_gpu_va_allocator_allocate(struct vkd3d_gpu_va_allocator *allocator,
- size_t alignment, size_t size, void *ptr) DECLSPEC_HIDDEN;
+ size_t alignment, size_t size, void *ptr);
void *vkd3d_gpu_va_allocator_dereference(struct vkd3d_gpu_va_allocator *allocator,
- D3D12_GPU_VIRTUAL_ADDRESS address) DECLSPEC_HIDDEN;
+ D3D12_GPU_VIRTUAL_ADDRESS address);
void vkd3d_gpu_va_allocator_free(struct vkd3d_gpu_va_allocator *allocator,
- D3D12_GPU_VIRTUAL_ADDRESS address) DECLSPEC_HIDDEN;
+ D3D12_GPU_VIRTUAL_ADDRESS address);
struct vkd3d_render_pass_key
{
@@ -257,11 +257,11 @@ struct vkd3d_render_pass_cache
};
void vkd3d_render_pass_cache_cleanup(struct vkd3d_render_pass_cache *cache,
- struct d3d12_device *device) DECLSPEC_HIDDEN;
+ struct d3d12_device *device);
HRESULT vkd3d_render_pass_cache_find(struct vkd3d_render_pass_cache *cache,
struct d3d12_device *device, const struct vkd3d_render_pass_key *key,
- VkRenderPass *vk_render_pass) DECLSPEC_HIDDEN;
-void vkd3d_render_pass_cache_init(struct vkd3d_render_pass_cache *cache) DECLSPEC_HIDDEN;
+ VkRenderPass *vk_render_pass);
+void vkd3d_render_pass_cache_init(struct vkd3d_render_pass_cache *cache);
struct vkd3d_private_store
{
@@ -317,11 +317,11 @@ static inline void vkd3d_private_store_destroy(struct vkd3d_private_store *store
}
HRESULT vkd3d_get_private_data(struct vkd3d_private_store *store,
- const GUID *tag, unsigned int *out_size, void *out) DECLSPEC_HIDDEN;
+ const GUID *tag, unsigned int *out_size, void *out);
HRESULT vkd3d_set_private_data(struct vkd3d_private_store *store,
- const GUID *tag, unsigned int data_size, const void *data) DECLSPEC_HIDDEN;
+ const GUID *tag, unsigned int data_size, const void *data);
HRESULT vkd3d_set_private_data_interface(struct vkd3d_private_store *store,
- const GUID *tag, const IUnknown *object) DECLSPEC_HIDDEN;
+ const GUID *tag, const IUnknown *object);
struct vkd3d_signaled_semaphore
{
@@ -362,7 +362,7 @@ struct d3d12_fence
};
HRESULT d3d12_fence_create(struct d3d12_device *device,
- uint64_t initial_value, D3D12_FENCE_FLAGS flags, struct d3d12_fence **fence) DECLSPEC_HIDDEN;
+ uint64_t initial_value, D3D12_FENCE_FLAGS flags, struct d3d12_fence **fence);
/* ID3D12Heap */
struct d3d12_heap
@@ -386,8 +386,8 @@ struct d3d12_heap
};
HRESULT d3d12_heap_create(struct d3d12_device *device, const D3D12_HEAP_DESC *desc,
- const struct d3d12_resource *resource, struct d3d12_heap **heap) DECLSPEC_HIDDEN;
-struct d3d12_heap *unsafe_impl_from_ID3D12Heap(ID3D12Heap *iface) DECLSPEC_HIDDEN;
+ const struct d3d12_resource *resource, struct d3d12_heap **heap);
+struct d3d12_heap *unsafe_impl_from_ID3D12Heap(ID3D12Heap *iface);
#define VKD3D_RESOURCE_PUBLIC_FLAGS \
(VKD3D_RESOURCE_INITIAL_STATE_TRANSITION | VKD3D_RESOURCE_PRESENT_STATE_TRANSITION)
@@ -435,29 +435,29 @@ static inline bool d3d12_resource_is_texture(const struct d3d12_resource *resour
return resource->desc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER;
}
-bool d3d12_resource_is_cpu_accessible(const struct d3d12_resource *resource) DECLSPEC_HIDDEN;
-HRESULT d3d12_resource_validate_desc(const D3D12_RESOURCE_DESC *desc, struct d3d12_device *device) DECLSPEC_HIDDEN;
+bool d3d12_resource_is_cpu_accessible(const struct d3d12_resource *resource);
+HRESULT d3d12_resource_validate_desc(const D3D12_RESOURCE_DESC *desc, struct d3d12_device *device);
HRESULT d3d12_committed_resource_create(struct d3d12_device *device,
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
- const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource) DECLSPEC_HIDDEN;
+ const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource);
HRESULT d3d12_placed_resource_create(struct d3d12_device *device, struct d3d12_heap *heap, uint64_t heap_offset,
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
- const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource) DECLSPEC_HIDDEN;
+ const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource);
HRESULT d3d12_reserved_resource_create(struct d3d12_device *device,
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
- const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource) DECLSPEC_HIDDEN;
-struct d3d12_resource *unsafe_impl_from_ID3D12Resource(ID3D12Resource *iface) DECLSPEC_HIDDEN;
+ const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource);
+struct d3d12_resource *unsafe_impl_from_ID3D12Resource(ID3D12Resource *iface);
HRESULT vkd3d_allocate_buffer_memory(struct d3d12_device *device, VkBuffer vk_buffer,
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
- VkDeviceMemory *vk_memory, uint32_t *vk_memory_type, VkDeviceSize *vk_memory_size) DECLSPEC_HIDDEN;
+ VkDeviceMemory *vk_memory, uint32_t *vk_memory_type, VkDeviceSize *vk_memory_size);
HRESULT vkd3d_create_buffer(struct d3d12_device *device,
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
- const D3D12_RESOURCE_DESC *desc, VkBuffer *vk_buffer) DECLSPEC_HIDDEN;
+ const D3D12_RESOURCE_DESC *desc, VkBuffer *vk_buffer);
HRESULT vkd3d_get_image_allocation_info(struct d3d12_device *device,
- const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_ALLOCATION_INFO *allocation_info) DECLSPEC_HIDDEN;
+ const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_ALLOCATION_INFO *allocation_info);
enum vkd3d_view_type
{
@@ -495,8 +495,8 @@ struct vkd3d_view
} info;
};
-void vkd3d_view_decref(struct vkd3d_view *view, struct d3d12_device *device) DECLSPEC_HIDDEN;
-void vkd3d_view_incref(struct vkd3d_view *view) DECLSPEC_HIDDEN;
+void vkd3d_view_decref(struct vkd3d_view *view, struct d3d12_device *device);
+void vkd3d_view_incref(struct vkd3d_view *view);
struct vkd3d_texture_view_desc
{
@@ -511,9 +511,9 @@ struct vkd3d_texture_view_desc
};
bool vkd3d_create_buffer_view(struct d3d12_device *device, VkBuffer vk_buffer, const struct vkd3d_format *format,
- VkDeviceSize offset, VkDeviceSize size, struct vkd3d_view **view) DECLSPEC_HIDDEN;
+ VkDeviceSize offset, VkDeviceSize size, struct vkd3d_view **view);
bool vkd3d_create_texture_view(struct d3d12_device *device, VkImage vk_image,
- const struct vkd3d_texture_view_desc *desc, struct vkd3d_view **view) DECLSPEC_HIDDEN;
+ const struct vkd3d_texture_view_desc *desc, struct vkd3d_view **view);
struct d3d12_desc
{
@@ -537,24 +537,24 @@ static inline struct d3d12_desc *d3d12_desc_from_gpu_handle(D3D12_GPU_DESCRIPTOR
}
void d3d12_desc_copy(struct d3d12_desc *dst, const struct d3d12_desc *src,
- struct d3d12_device *device) DECLSPEC_HIDDEN;
+ struct d3d12_device *device);
void d3d12_desc_create_cbv(struct d3d12_desc *descriptor,
- struct d3d12_device *device, const D3D12_CONSTANT_BUFFER_VIEW_DESC *desc) DECLSPEC_HIDDEN;
+ struct d3d12_device *device, const D3D12_CONSTANT_BUFFER_VIEW_DESC *desc);
void d3d12_desc_create_srv(struct d3d12_desc *descriptor,
struct d3d12_device *device, struct d3d12_resource *resource,
- const D3D12_SHADER_RESOURCE_VIEW_DESC *desc) DECLSPEC_HIDDEN;
+ const D3D12_SHADER_RESOURCE_VIEW_DESC *desc);
void d3d12_desc_create_uav(struct d3d12_desc *descriptor, struct d3d12_device *device,
struct d3d12_resource *resource, struct d3d12_resource *counter_resource,
- const D3D12_UNORDERED_ACCESS_VIEW_DESC *desc) DECLSPEC_HIDDEN;
+ const D3D12_UNORDERED_ACCESS_VIEW_DESC *desc);
void d3d12_desc_create_sampler(struct d3d12_desc *sampler,
- struct d3d12_device *device, const D3D12_SAMPLER_DESC *desc) DECLSPEC_HIDDEN;
+ struct d3d12_device *device, const D3D12_SAMPLER_DESC *desc);
void d3d12_desc_write_atomic(struct d3d12_desc *dst, const struct d3d12_desc *src,
- struct d3d12_device *device) DECLSPEC_HIDDEN;
+ struct d3d12_device *device);
bool vkd3d_create_raw_buffer_view(struct d3d12_device *device,
- D3D12_GPU_VIRTUAL_ADDRESS gpu_address, VkBufferView *vk_buffer_view) DECLSPEC_HIDDEN;
+ D3D12_GPU_VIRTUAL_ADDRESS gpu_address, VkBufferView *vk_buffer_view);
HRESULT vkd3d_create_static_sampler(struct d3d12_device *device,
- const D3D12_STATIC_SAMPLER_DESC *desc, VkSampler *vk_sampler) DECLSPEC_HIDDEN;
+ const D3D12_STATIC_SAMPLER_DESC *desc, VkSampler *vk_sampler);
struct d3d12_rtv_desc
{
@@ -574,7 +574,7 @@ static inline struct d3d12_rtv_desc *d3d12_rtv_desc_from_cpu_handle(D3D12_CPU_DE
}
void d3d12_rtv_desc_create_rtv(struct d3d12_rtv_desc *rtv_desc, struct d3d12_device *device,
- struct d3d12_resource *resource, const D3D12_RENDER_TARGET_VIEW_DESC *desc) DECLSPEC_HIDDEN;
+ struct d3d12_resource *resource, const D3D12_RENDER_TARGET_VIEW_DESC *desc);
struct d3d12_dsv_desc
{
@@ -594,7 +594,7 @@ static inline struct d3d12_dsv_desc *d3d12_dsv_desc_from_cpu_handle(D3D12_CPU_DE
}
void d3d12_dsv_desc_create_dsv(struct d3d12_dsv_desc *dsv_desc, struct d3d12_device *device,
- struct d3d12_resource *resource, const D3D12_DEPTH_STENCIL_VIEW_DESC *desc) DECLSPEC_HIDDEN;
+ struct d3d12_resource *resource, const D3D12_DEPTH_STENCIL_VIEW_DESC *desc);
/* ID3D12DescriptorHeap */
struct d3d12_descriptor_heap
@@ -612,7 +612,7 @@ struct d3d12_descriptor_heap
};
HRESULT d3d12_descriptor_heap_create(struct d3d12_device *device,
- const D3D12_DESCRIPTOR_HEAP_DESC *desc, struct d3d12_descriptor_heap **descriptor_heap) DECLSPEC_HIDDEN;
+ const D3D12_DESCRIPTOR_HEAP_DESC *desc, struct d3d12_descriptor_heap **descriptor_heap);
/* ID3D12QueryHeap */
struct d3d12_query_heap
@@ -630,8 +630,8 @@ struct d3d12_query_heap
};
HRESULT d3d12_query_heap_create(struct d3d12_device *device, const D3D12_QUERY_HEAP_DESC *desc,
- struct d3d12_query_heap **heap) DECLSPEC_HIDDEN;
-struct d3d12_query_heap *unsafe_impl_from_ID3D12QueryHeap(ID3D12QueryHeap *iface) DECLSPEC_HIDDEN;
+ struct d3d12_query_heap **heap);
+struct d3d12_query_heap *unsafe_impl_from_ID3D12QueryHeap(ID3D12QueryHeap *iface);
/* A Vulkan query has to be issued at least one time before the result is
* available. In D3D12 it is legal to get query reults for not issued queries.
@@ -731,11 +731,11 @@ struct d3d12_root_signature
};
HRESULT d3d12_root_signature_create(struct d3d12_device *device, const void *bytecode,
- size_t bytecode_length, struct d3d12_root_signature **root_signature) DECLSPEC_HIDDEN;
-struct d3d12_root_signature *unsafe_impl_from_ID3D12RootSignature(ID3D12RootSignature *iface) DECLSPEC_HIDDEN;
+ size_t bytecode_length, struct d3d12_root_signature **root_signature);
+struct d3d12_root_signature *unsafe_impl_from_ID3D12RootSignature(ID3D12RootSignature *iface);
int vkd3d_parse_root_signature_v_1_0(const struct vkd3d_shader_code *dxbc,
- struct vkd3d_shader_versioned_root_signature_desc *desc) DECLSPEC_HIDDEN;
+ struct vkd3d_shader_versioned_root_signature_desc *desc);
struct d3d12_graphics_pipeline_state
{
@@ -829,13 +829,13 @@ static inline bool d3d12_pipeline_state_has_unknown_dsv_format(struct d3d12_pipe
}
HRESULT d3d12_pipeline_state_create_compute(struct d3d12_device *device,
- const D3D12_COMPUTE_PIPELINE_STATE_DESC *desc, struct d3d12_pipeline_state **state) DECLSPEC_HIDDEN;
+ const D3D12_COMPUTE_PIPELINE_STATE_DESC *desc, struct d3d12_pipeline_state **state);
HRESULT d3d12_pipeline_state_create_graphics(struct d3d12_device *device,
- const D3D12_GRAPHICS_PIPELINE_STATE_DESC *desc, struct d3d12_pipeline_state **state) DECLSPEC_HIDDEN;
+ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *desc, struct d3d12_pipeline_state **state);
VkPipeline d3d12_pipeline_state_get_or_create_pipeline(struct d3d12_pipeline_state *state,
D3D12_PRIMITIVE_TOPOLOGY topology, const uint32_t *strides, VkFormat dsv_format,
- VkRenderPass *vk_render_pass) DECLSPEC_HIDDEN;
-struct d3d12_pipeline_state *unsafe_impl_from_ID3D12PipelineState(ID3D12PipelineState *iface) DECLSPEC_HIDDEN;
+ VkRenderPass *vk_render_pass);
+struct d3d12_pipeline_state *unsafe_impl_from_ID3D12PipelineState(ID3D12PipelineState *iface);
struct vkd3d_buffer
{
@@ -895,7 +895,7 @@ struct d3d12_command_allocator
};
HRESULT d3d12_command_allocator_create(struct d3d12_device *device,
- D3D12_COMMAND_LIST_TYPE type, struct d3d12_command_allocator **allocator) DECLSPEC_HIDDEN;
+ D3D12_COMMAND_LIST_TYPE type, struct d3d12_command_allocator **allocator);
struct vkd3d_push_descriptor
{
@@ -987,7 +987,7 @@ struct d3d12_command_list
HRESULT d3d12_command_list_create(struct d3d12_device *device,
UINT node_mask, D3D12_COMMAND_LIST_TYPE type, ID3D12CommandAllocator *allocator_iface,
- ID3D12PipelineState *initial_pipeline_state, struct d3d12_command_list **list) DECLSPEC_HIDDEN;
+ ID3D12PipelineState *initial_pipeline_state, struct d3d12_command_list **list);
struct vkd3d_queue
{
@@ -1014,12 +1014,12 @@ struct vkd3d_queue
VkSemaphore old_vk_semaphores[VKD3D_MAX_VK_SYNC_OBJECTS];
};
-VkQueue vkd3d_queue_acquire(struct vkd3d_queue *queue) DECLSPEC_HIDDEN;
+VkQueue vkd3d_queue_acquire(struct vkd3d_queue *queue);
HRESULT vkd3d_queue_create(struct d3d12_device *device,
uint32_t family_index, const VkQueueFamilyProperties *properties,
- struct vkd3d_queue **queue) DECLSPEC_HIDDEN;
-void vkd3d_queue_destroy(struct vkd3d_queue *queue, struct d3d12_device *device) DECLSPEC_HIDDEN;
-void vkd3d_queue_release(struct vkd3d_queue *queue) DECLSPEC_HIDDEN;
+ struct vkd3d_queue **queue);
+void vkd3d_queue_destroy(struct vkd3d_queue *queue, struct d3d12_device *device);
+void vkd3d_queue_release(struct vkd3d_queue *queue);
/* ID3D12CommandQueue */
struct d3d12_command_queue
@@ -1040,7 +1040,7 @@ struct d3d12_command_queue
};
HRESULT d3d12_command_queue_create(struct d3d12_device *device,
- const D3D12_COMMAND_QUEUE_DESC *desc, struct d3d12_command_queue **queue) DECLSPEC_HIDDEN;
+ const D3D12_COMMAND_QUEUE_DESC *desc, struct d3d12_command_queue **queue);
/* ID3D12CommandSignature */
struct d3d12_command_signature
@@ -1056,8 +1056,8 @@ struct d3d12_command_signature
};
HRESULT d3d12_command_signature_create(struct d3d12_device *device, const D3D12_COMMAND_SIGNATURE_DESC *desc,
- struct d3d12_command_signature **signature) DECLSPEC_HIDDEN;
-struct d3d12_command_signature *unsafe_impl_from_ID3D12CommandSignature(ID3D12CommandSignature *iface) DECLSPEC_HIDDEN;
+ struct d3d12_command_signature **signature);
+struct d3d12_command_signature *unsafe_impl_from_ID3D12CommandSignature(ID3D12CommandSignature *iface);
/* NULL resources */
struct vkd3d_null_resources
@@ -1076,9 +1076,9 @@ struct vkd3d_null_resources
};
HRESULT vkd3d_init_null_resources(struct vkd3d_null_resources *null_resources,
- struct d3d12_device *device) DECLSPEC_HIDDEN;
+ struct d3d12_device *device);
void vkd3d_destroy_null_resources(struct vkd3d_null_resources *null_resources,
- struct d3d12_device *device) DECLSPEC_HIDDEN;
+ struct d3d12_device *device);
struct vkd3d_format_compatibility_list
{
@@ -1116,8 +1116,8 @@ struct vkd3d_uav_clear_state
struct vkd3d_uav_clear_pipelines pipelines_uint;
};
-HRESULT vkd3d_uav_clear_state_init(struct vkd3d_uav_clear_state *state, struct d3d12_device *device) DECLSPEC_HIDDEN;
-void vkd3d_uav_clear_state_cleanup(struct vkd3d_uav_clear_state *state, struct d3d12_device *device) DECLSPEC_HIDDEN;
+HRESULT vkd3d_uav_clear_state_init(struct vkd3d_uav_clear_state *state, struct d3d12_device *device);
+void vkd3d_uav_clear_state_cleanup(struct vkd3d_uav_clear_state *state, struct d3d12_device *device);
/* ID3D12Device */
struct d3d12_device
@@ -1173,13 +1173,13 @@ struct d3d12_device
};
HRESULT d3d12_device_create(struct vkd3d_instance *instance,
- const struct vkd3d_device_create_info *create_info, struct d3d12_device **device) DECLSPEC_HIDDEN;
+ const struct vkd3d_device_create_info *create_info, struct d3d12_device **device);
struct vkd3d_queue *d3d12_device_get_vkd3d_queue(struct d3d12_device *device,
- D3D12_COMMAND_LIST_TYPE type) DECLSPEC_HIDDEN;
-bool d3d12_device_is_uma(struct d3d12_device *device, bool *coherent) DECLSPEC_HIDDEN;
+ D3D12_COMMAND_LIST_TYPE type);
+bool d3d12_device_is_uma(struct d3d12_device *device, bool *coherent);
void d3d12_device_mark_as_removed(struct d3d12_device *device, HRESULT reason,
- const char *message, ...) VKD3D_PRINTF_FUNC(3, 4) DECLSPEC_HIDDEN;
-struct d3d12_device *unsafe_impl_from_ID3D12Device(ID3D12Device *iface) DECLSPEC_HIDDEN;
+ const char *message, ...) VKD3D_PRINTF_FUNC(3, 4);
+struct d3d12_device *unsafe_impl_from_ID3D12Device(ID3D12Device *iface);
static inline HRESULT d3d12_device_query_interface(struct d3d12_device *device, REFIID iid, void **object)
{
@@ -1254,15 +1254,15 @@ static inline bool vkd3d_format_is_compressed(const struct vkd3d_format *format)
void vkd3d_format_copy_data(const struct vkd3d_format *format, const uint8_t *src,
unsigned int src_row_pitch, unsigned int src_slice_pitch, uint8_t *dst, unsigned int dst_row_pitch,
- unsigned int dst_slice_pitch, unsigned int w, unsigned int h, unsigned int d) DECLSPEC_HIDDEN;
+ unsigned int dst_slice_pitch, unsigned int w, unsigned int h, unsigned int d);
const struct vkd3d_format *vkd3d_get_format(const struct d3d12_device *device,
- DXGI_FORMAT dxgi_format, bool depth_stencil) DECLSPEC_HIDDEN;
+ DXGI_FORMAT dxgi_format, bool depth_stencil);
const struct vkd3d_format *vkd3d_find_uint_format(const struct d3d12_device *device,
- DXGI_FORMAT dxgi_format) DECLSPEC_HIDDEN;
+ DXGI_FORMAT dxgi_format);
-HRESULT vkd3d_init_format_info(struct d3d12_device *device) DECLSPEC_HIDDEN;
-void vkd3d_cleanup_format_info(struct d3d12_device *device) DECLSPEC_HIDDEN;
+HRESULT vkd3d_init_format_info(struct d3d12_device *device);
+void vkd3d_cleanup_format_info(struct d3d12_device *device);
static inline const struct vkd3d_format *vkd3d_format_from_d3d12_resource_desc(
const struct d3d12_device *device, const D3D12_RESOURCE_DESC *desc, DXGI_FORMAT view_format)
@@ -1310,24 +1310,24 @@ static inline unsigned int vkd3d_compute_workgroup_count(unsigned int thread_cou
return (thread_count + workgroup_size - 1) / workgroup_size;
}
-VkCompareOp vk_compare_op_from_d3d12(D3D12_COMPARISON_FUNC op) DECLSPEC_HIDDEN;
-VkSampleCountFlagBits vk_samples_from_dxgi_sample_desc(const DXGI_SAMPLE_DESC *desc) DECLSPEC_HIDDEN;
-VkSampleCountFlagBits vk_samples_from_sample_count(unsigned int sample_count) DECLSPEC_HIDDEN;
+VkCompareOp vk_compare_op_from_d3d12(D3D12_COMPARISON_FUNC op);
+VkSampleCountFlagBits vk_samples_from_dxgi_sample_desc(const DXGI_SAMPLE_DESC *desc);
+VkSampleCountFlagBits vk_samples_from_sample_count(unsigned int sample_count);
-bool is_valid_feature_level(D3D_FEATURE_LEVEL feature_level) DECLSPEC_HIDDEN;
+bool is_valid_feature_level(D3D_FEATURE_LEVEL feature_level);
-bool is_valid_resource_state(D3D12_RESOURCE_STATES state) DECLSPEC_HIDDEN;
-bool is_write_resource_state(D3D12_RESOURCE_STATES state) DECLSPEC_HIDDEN;
+bool is_valid_resource_state(D3D12_RESOURCE_STATES state);
+bool is_write_resource_state(D3D12_RESOURCE_STATES state);
HRESULT return_interface(void *iface, REFIID iface_iid,
- REFIID requested_iid, void **object) DECLSPEC_HIDDEN;
+ REFIID requested_iid, void **object);
-const char *debug_d3d12_box(const D3D12_BOX *box) DECLSPEC_HIDDEN;
-const char *debug_d3d12_shader_component_mapping(unsigned int mapping) DECLSPEC_HIDDEN;
-const char *debug_vk_extent_3d(VkExtent3D extent) DECLSPEC_HIDDEN;
-const char *debug_vk_memory_heap_flags(VkMemoryHeapFlags flags) DECLSPEC_HIDDEN;
-const char *debug_vk_memory_property_flags(VkMemoryPropertyFlags flags) DECLSPEC_HIDDEN;
-const char *debug_vk_queue_flags(VkQueueFlags flags) DECLSPEC_HIDDEN;
+const char *debug_d3d12_box(const D3D12_BOX *box);
+const char *debug_d3d12_shader_component_mapping(unsigned int mapping);
+const char *debug_vk_extent_3d(VkExtent3D extent);
+const char *debug_vk_memory_heap_flags(VkMemoryHeapFlags flags);
+const char *debug_vk_memory_property_flags(VkMemoryPropertyFlags flags);
+const char *debug_vk_queue_flags(VkQueueFlags flags);
static inline void debug_ignored_node_mask(unsigned int mask)
{
@@ -1336,15 +1336,15 @@ static inline void debug_ignored_node_mask(unsigned int mask)
}
HRESULT vkd3d_load_vk_global_procs(struct vkd3d_vk_global_procs *procs,
- PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr) DECLSPEC_HIDDEN;
+ PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr);
HRESULT vkd3d_load_vk_instance_procs(struct vkd3d_vk_instance_procs *procs,
- const struct vkd3d_vk_global_procs *global_procs, VkInstance instance) DECLSPEC_HIDDEN;
+ const struct vkd3d_vk_global_procs *global_procs, VkInstance instance);
HRESULT vkd3d_load_vk_device_procs(struct vkd3d_vk_device_procs *procs,
- const struct vkd3d_vk_instance_procs *parent_procs, VkDevice device) DECLSPEC_HIDDEN;
+ const struct vkd3d_vk_instance_procs *parent_procs, VkDevice device);
extern const char vkd3d_build[];
-bool vkd3d_get_program_name(char program_name[PATH_MAX]) DECLSPEC_HIDDEN;
+bool vkd3d_get_program_name(char program_name[PATH_MAX]);
static inline void vkd3d_set_thread_name(const char *name)
{
@@ -1356,9 +1356,9 @@ static inline void vkd3d_set_thread_name(const char *name)
}
VkResult vkd3d_set_vk_object_name_utf8(struct d3d12_device *device, uint64_t vk_object,
- VkDebugReportObjectTypeEXT vk_object_type, const char *name) DECLSPEC_HIDDEN;
+ VkDebugReportObjectTypeEXT vk_object_type, const char *name);
HRESULT vkd3d_set_vk_object_name(struct d3d12_device *device, uint64_t vk_object,
- VkDebugReportObjectTypeEXT vk_object_type, const WCHAR *name) DECLSPEC_HIDDEN;
+ VkDebugReportObjectTypeEXT vk_object_type, const WCHAR *name);
static inline void vk_prepend_struct(void *header, void *structure)
{
--
2.28.0
5
6
[PATCH 4/4] shell32/tests: Add tests to show relative known folder paths match SHGetKnownFolderPath
by Andrew Eikum 19 Jun '21
by Andrew Eikum 19 Jun '21
19 Jun '21
Signed-off-by: Andrew Eikum <aeikum(a)codeweavers.com>
---
dlls/shell32/tests/shellpath.c | 64 ++++++++++++++++++++++++++++++++--
1 file changed, 62 insertions(+), 2 deletions(-)
diff --git a/dlls/shell32/tests/shellpath.c b/dlls/shell32/tests/shellpath.c
index 4c9b9693983..504812bad5d 100644
--- a/dlls/shell32/tests/shellpath.c
+++ b/dlls/shell32/tests/shellpath.c
@@ -291,6 +291,18 @@ static const char *getFolderName(int folder)
}
}
+LPWSTR wcscasestr( LPCWSTR str, LPCWSTR sub )
+{
+ while (*str)
+ {
+ const WCHAR *p1 = str, *p2 = sub;
+ while (*p1 && *p2 && towlower(*p1) == towlower(*p2)) { p1++; p2++; }
+ if (!*p2) return (WCHAR *)str;
+ str++;
+ }
+ return NULL;
+}
+
/* Standard CSIDL values (and their flags) uses only two less-significant bytes */
#define NO_CSIDL 0x10000
#define WINE_ATTRIBUTES_OPTIONAL 0x20000
@@ -1964,10 +1976,11 @@ static void check_known_folder(IKnownFolderManager *mgr, KNOWNFOLDERID *folderId
HRESULT hr;
int csidl, expectedCsidl, ret;
KNOWNFOLDER_DEFINITION kfd;
- IKnownFolder *folder;
+ IKnownFolder *folder, *kf_parent;
WCHAR sName[1024];
BOOL found = FALSE;
unsigned int i;
+ WCHAR *ikf_path, *gkfp_path, *ikf_parent_path;
for (i = 0; i < ARRAY_SIZE(known_folders); ++i)
{
@@ -2019,10 +2032,57 @@ static void check_known_folder(IKnownFolderManager *mgr, KNOWNFOLDERID *folderId
ok_(__FILE__, known_folder->line)(!(kfd.kfdFlags & (~known_folder->definitionFlags)), "invalid known folder flags for %s: 0x%08x expected, but 0x%08x retrieved\n", known_folder->sFolderId, known_folder->definitionFlags, kfd.kfdFlags);
+ gkfp_path = NULL;
+ hr = pSHGetKnownFolderPath(folderId, KF_FLAG_DEFAULT, NULL, &gkfp_path);
+ if(SUCCEEDED(hr))
+ {
+ ikf_path = NULL;
+ hr = IKnownFolder_GetPath(folder, KF_FLAG_DEFAULT, &ikf_path);
+ ok_(__FILE__, known_folder->line)(hr == S_OK, "IKnownFolder::GetPath failed: 0x%08x\n", hr);
+ ok_(__FILE__, known_folder->line)(ikf_path != NULL, "SHGetKnownFolderPath gave NULL path\n");
+
+ /* IKnownFolder::GetPath and SHGetKnownFolderPath should be the same */
+ ok_(__FILE__, known_folder->line)(lstrcmpW(gkfp_path, ikf_path) == 0, "Got different paths: %s vs %s\n",
+ debugstr_w(gkfp_path), debugstr_w(ikf_path));
+
+ if(kfd.pszRelativePath)
+ {
+ /* RelativePath should be a substring of the path */
+ ok_(__FILE__, known_folder->line)(wcscasestr(ikf_path, kfd.pszRelativePath) != NULL,
+ "KNOWNFOLDER_DEFINITION.pszRelativePath %s is not a substring of full path %s\n",
+ debugstr_w(kfd.pszRelativePath), debugstr_w(ikf_path));
+
+ hr = IKnownFolderManager_GetFolder(mgr, &kfd.fidParent, &kf_parent);
+ ok_(__FILE__, known_folder->line)(hr == S_OK, "IKnownFolderManager::GetFolder(parent) failed: 0x%08x\n", hr);
+
+ if(SUCCEEDED(hr))
+ {
+ ikf_parent_path = NULL;
+ hr = IKnownFolder_GetPath(kf_parent, KF_FLAG_DEFAULT, &ikf_parent_path);
+ ok_(__FILE__, known_folder->line)(hr == S_OK, "IKnownFolder::GetPath(parent) failed: 0x%08x\n", hr);
+
+ /* Parent path + pszRelativePath should give the full path */
+ ok_(__FILE__, known_folder->line)(memcmp(ikf_parent_path, ikf_path, lstrlenW(ikf_parent_path) * sizeof(WCHAR)) == 0,
+ "Full path %s does not start with parent path %s\n",
+ debugstr_w(ikf_path), debugstr_w(ikf_parent_path));
+ ok_(__FILE__, known_folder->line)(*(ikf_path + lstrlenW(ikf_parent_path)) == '\\',
+ "Missing slash\n");
+ ok_(__FILE__, known_folder->line)(wcsicmp(kfd.pszRelativePath, ikf_path + lstrlenW(ikf_parent_path) + 1) == 0,
+ "Full path %s does not end with relative path %s\n",
+ debugstr_w(ikf_path), debugstr_w(kfd.pszRelativePath));
+
+ CoTaskMemFree(ikf_parent_path);
+ IKnownFolder_Release(kf_parent);
+ }
+ }
+
+ CoTaskMemFree(ikf_path);
+ CoTaskMemFree(gkfp_path);
+ }
FreeKnownFolderDefinitionFields(&kfd);
}
- IKnownFolder_Release(folder);
+ IKnownFolder_Release(folder);
}
break;
--
2.31.1
2
2
14 Jun '21
COLORONCOLOR(STRETCH_DELETESCANS) was used in place of HALFTONE. COLORONCOLOR mode may delete rows
of pixels without trying to preserve information so it will cause Wine to render poorly when the
destination rectangle is small.
According to tests, HALFTONE mode uses box filter when doing integer downscaling and nearest
neighbor interpolation when doing upscaling in both horizontally and vertically. In other cases,
HALFTONE mode uses a lanczos3 like algorithm to interpolate pixels. There are also other heuristics
involved. For example, shrinking a 2x2 image to 1x1 may not use box filter depending on image data.
Since this algorithm is undocumented, it's difficult to reverse engineer the original algorithm and
produce identical results. Instead, this patch uses a naive implementation of bilinear interpolation
to implement HALFTONE mode and it produces good quality images.
For 8-bit and lower color depth images, nulldrv_StretchBlt should resize the images first and then
converts color depth.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46375
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/gdi32/dibdrv/bitblt.c | 7 +
dlls/gdi32/dibdrv/dibdrv.h | 2 +
dlls/gdi32/dibdrv/primitives.c | 629 ++++++++++++++++++++++++++++++++-
3 files changed, 629 insertions(+), 9 deletions(-)
diff --git a/dlls/gdi32/dibdrv/bitblt.c b/dlls/gdi32/dibdrv/bitblt.c
index d2f59965b02..9b46ad2916f 100644
--- a/dlls/gdi32/dibdrv/bitblt.c
+++ b/dlls/gdi32/dibdrv/bitblt.c
@@ -1216,6 +1216,12 @@ DWORD stretch_bitmapinfo( const BITMAPINFO *src_info, void *src_bits, struct bit
init_dib_info_from_bitmapinfo( &src_dib, src_info, src_bits );
init_dib_info_from_bitmapinfo( &dst_dib, dst_info, dst_bits );
+ if (mode == HALFTONE)
+ {
+ dst_dib.funcs->halftone( &dst_dib, dst, &src_dib, src );
+ goto done;
+ }
+
/* v */
ret = calc_1d_stretch_params( dst->y, dst->height, dst->visrect.top, dst->visrect.bottom,
src->y, src->height, src->visrect.top, src->visrect.bottom,
@@ -1300,6 +1306,7 @@ DWORD stretch_bitmapinfo( const BITMAPINFO *src_info, void *src_bits, struct bit
}
}
+done:
/* update coordinates, the destination rectangle is always stored at 0,0 */
*src = *dst;
src->x -= src->visrect.left;
diff --git a/dlls/gdi32/dibdrv/dibdrv.h b/dlls/gdi32/dibdrv/dibdrv.h
index d3a35b96c75..0492c0bd51e 100644
--- a/dlls/gdi32/dibdrv/dibdrv.h
+++ b/dlls/gdi32/dibdrv/dibdrv.h
@@ -211,6 +211,8 @@ typedef struct primitive_funcs
void (* shrink_row)(const dib_info *dst_dib, const POINT *dst_start,
const dib_info *src_dib, const POINT *src_start,
const struct stretch_params *params, int mode, BOOL keep_dst);
+ void (* halftone)(const dib_info *dst_dib, const struct bitblt_coords *dst,
+ const dib_info *src_dib, const struct bitblt_coords *src);
} primitive_funcs;
extern const primitive_funcs funcs_8888 DECLSPEC_HIDDEN;
diff --git a/dlls/gdi32/dibdrv/primitives.c b/dlls/gdi32/dibdrv/primitives.c
index e4b18a6656d..5eca124b918 100644
--- a/dlls/gdi32/dibdrv/primitives.c
+++ b/dlls/gdi32/dibdrv/primitives.c
@@ -7430,6 +7430,608 @@ static void shrink_row_null(const dib_info *dst_dib, const POINT *dst_start,
return;
}
+static float clampf( float value, float min, float max )
+{
+ return max( min, min( value, max ) );
+}
+
+static int clamp( int value, int min, int max )
+{
+ return max( min, min( value, max ) );
+}
+
+static BYTE linear_interpolate( BYTE start, BYTE end, float delta )
+{
+ return start + (end - start) * delta + 0.5f;
+}
+
+static BYTE bilinear_interpolate( BYTE c00, BYTE c01, BYTE c10, BYTE c11, float dx, float dy )
+{
+ return linear_interpolate( linear_interpolate( c00, c01, dx ),
+ linear_interpolate( c10, c11, dx ), dy );
+}
+
+static void calc_halftone_params( const struct bitblt_coords *dst, const struct bitblt_coords *src,
+ RECT *dst_rect, RECT *src_rect, int *src_start_x,
+ int *src_start_y, float *src_inc_x, float *src_inc_y )
+{
+ int src_width, src_height, dst_width, dst_height;
+ BOOL mirrored_x, mirrored_y;
+
+ get_bounding_rect( src_rect, src->x, src->y, src->width, src->height );
+ get_bounding_rect( dst_rect, dst->x, dst->y, dst->width, dst->height );
+ intersect_rect( src_rect, &src->visrect, src_rect );
+ intersect_rect( dst_rect, &dst->visrect, dst_rect );
+ offset_rect( dst_rect, -dst_rect->left, -dst_rect->top );
+
+ src_width = src_rect->right - src_rect->left;
+ src_height = src_rect->bottom - src_rect->top;
+ dst_width = dst_rect->right - dst_rect->left;
+ dst_height = dst_rect->bottom - dst_rect->top;
+
+ mirrored_x = (dst->width < 0) != (src->width < 0);
+ mirrored_y = (dst->height < 0) != (src->height < 0);
+ *src_start_x = mirrored_x ? src_rect->right - 1 : src_rect->left;
+ *src_start_y = mirrored_y ? src_rect->bottom - 1 : src_rect->top;
+ *src_inc_x = mirrored_x ? -(float)src_width / dst_width : (float)src_width / dst_width;
+ *src_inc_y = mirrored_y ? -(float)src_height / dst_height : (float)src_height / dst_height;
+}
+
+static void halftone_888( const dib_info *dst_dib, const struct bitblt_coords *dst,
+ const dib_info *src_dib, const struct bitblt_coords *src )
+{
+ int src_start_x, src_start_y, src_ptr_dy, dst_x, dst_y, x0, x1, y0, y1;
+ DWORD *dst_ptr, *src_ptr, *c00_ptr, *c01_ptr, *c10_ptr, *c11_ptr;
+ float src_inc_x, src_inc_y, float_x, float_y, dx, dy;
+ BYTE c00_r, c01_r, c10_r, c11_r;
+ BYTE c00_g, c01_g, c10_g, c11_g;
+ BYTE c00_b, c01_b, c10_b, c11_b;
+ RECT dst_rect, src_rect;
+ BYTE r, g, b;
+
+ calc_halftone_params( dst, src, &dst_rect, &src_rect, &src_start_x, &src_start_y, &src_inc_x,
+ &src_inc_y );
+
+ float_y = src_start_y;
+ dst_ptr = get_pixel_ptr_32( dst_dib, dst_rect.left, dst_rect.top );
+ for (dst_y = 0; dst_y < dst_rect.bottom - dst_rect.top; ++dst_y)
+ {
+ float_y = clampf( float_y, src_rect.top, src_rect.bottom - 1 );
+ y0 = float_y;
+ y1 = clamp( y0 + 1, src_rect.top, src_rect.bottom - 1 );
+ dy = float_y - y0;
+
+ float_x = src_start_x;
+ src_ptr = get_pixel_ptr_32( src_dib, 0, y0 );
+ src_ptr_dy = (y1 - y0) * src_dib->stride / 4;
+ for (dst_x = 0; dst_x < dst_rect.right - dst_rect.left; ++dst_x)
+ {
+ float_x = clampf( float_x, src_rect.left, src_rect.right - 1 );
+ x0 = float_x;
+ x1 = clamp( x0 + 1, src_rect.left, src_rect.right - 1 );
+ dx = float_x - x0;
+
+ c00_ptr = src_ptr + x0;
+ c01_ptr = src_ptr + x1;
+ c10_ptr = c00_ptr + src_ptr_dy;
+ c11_ptr = c01_ptr + src_ptr_dy;
+ c00_r = (*c00_ptr >> 16) & 0xff;
+ c01_r = (*c01_ptr >> 16) & 0xff;
+ c10_r = (*c10_ptr >> 16) & 0xff;
+ c11_r = (*c11_ptr >> 16) & 0xff;
+ c00_g = (*c00_ptr >> 8) & 0xff;
+ c01_g = (*c01_ptr >> 8) & 0xff;
+ c10_g = (*c10_ptr >> 8) & 0xff;
+ c11_g = (*c11_ptr >> 8) & 0xff;
+ c00_b = *c00_ptr & 0xff;
+ c01_b = *c01_ptr & 0xff;
+ c10_b = *c10_ptr & 0xff;
+ c11_b = *c11_ptr & 0xff;
+ r = bilinear_interpolate( c00_r, c01_r, c10_r, c11_r, dx, dy );
+ g = bilinear_interpolate( c00_g, c01_g, c10_g, c11_g, dx, dy );
+ b = bilinear_interpolate( c00_b, c01_b, c10_b, c11_b, dx, dy );
+ dst_ptr[dst_x] = ((r << 16) & 0xff0000) | ((g << 8) & 0x00ff00) | (b & 0x0000ff);
+
+ float_x += src_inc_x;
+ }
+
+ dst_ptr += dst_dib->stride / 4;
+ float_y += src_inc_y;
+ }
+}
+
+static void halftone_32( const dib_info *dst_dib, const struct bitblt_coords *dst,
+ const dib_info *src_dib, const struct bitblt_coords *src )
+{
+ int src_start_x, src_start_y, src_ptr_dy, dst_x, dst_y, x0, x1, y0, y1;
+ DWORD *dst_ptr, *src_ptr, *c00_ptr, *c01_ptr, *c10_ptr, *c11_ptr;
+ float src_inc_x, src_inc_y, float_x, float_y, dx, dy;
+ BYTE c00_r, c01_r, c10_r, c11_r;
+ BYTE c00_g, c01_g, c10_g, c11_g;
+ BYTE c00_b, c01_b, c10_b, c11_b;
+ RECT dst_rect, src_rect;
+ BYTE r, g, b;
+
+ calc_halftone_params( dst, src, &dst_rect, &src_rect, &src_start_x, &src_start_y, &src_inc_x,
+ &src_inc_y );
+
+ float_y = src_start_y;
+ dst_ptr = get_pixel_ptr_32( dst_dib, dst_rect.left, dst_rect.top );
+ for (dst_y = 0; dst_y < dst_rect.bottom - dst_rect.top; ++dst_y)
+ {
+ float_y = clampf( float_y, src_rect.top, src_rect.bottom - 1 );
+ y0 = float_y;
+ y1 = clamp( y0 + 1, src_rect.top, src_rect.bottom - 1 );
+ dy = float_y - y0;
+
+ float_x = src_start_x;
+ src_ptr = get_pixel_ptr_32( src_dib, 0, y0 );
+ src_ptr_dy = (y1 - y0) * src_dib->stride / 4;
+ for (dst_x = 0; dst_x < dst_rect.right - dst_rect.left; ++dst_x)
+ {
+ float_x = clampf( float_x, src_rect.left, src_rect.right - 1 );
+ x0 = float_x;
+ x1 = clamp( x0 + 1, src_rect.left, src_rect.right - 1 );
+ dx = float_x - x0;
+
+ c00_ptr = src_ptr + x0;
+ c01_ptr = src_ptr + x1;
+ c10_ptr = c00_ptr + src_ptr_dy;
+ c11_ptr = c01_ptr + src_ptr_dy;
+ c00_r = get_field( *c00_ptr, src_dib->red_shift, src_dib->red_len );
+ c01_r = get_field( *c01_ptr, src_dib->red_shift, src_dib->red_len );
+ c10_r = get_field( *c10_ptr, src_dib->red_shift, src_dib->red_len );
+ c11_r = get_field( *c11_ptr, src_dib->red_shift, src_dib->red_len );
+ c00_g = get_field( *c00_ptr, src_dib->green_shift, src_dib->green_len );
+ c01_g = get_field( *c01_ptr, src_dib->green_shift, src_dib->green_len );
+ c10_g = get_field( *c10_ptr, src_dib->green_shift, src_dib->green_len );
+ c11_g = get_field( *c11_ptr, src_dib->green_shift, src_dib->green_len );
+ c00_b = get_field( *c00_ptr, src_dib->blue_shift, src_dib->blue_len );
+ c01_b = get_field( *c01_ptr, src_dib->blue_shift, src_dib->blue_len );
+ c10_b = get_field( *c10_ptr, src_dib->blue_shift, src_dib->blue_len );
+ c11_b = get_field( *c11_ptr, src_dib->blue_shift, src_dib->blue_len );
+ r = bilinear_interpolate( c00_r, c01_r, c10_r, c11_r, dx, dy );
+ g = bilinear_interpolate( c00_g, c01_g, c10_g, c11_g, dx, dy );
+ b = bilinear_interpolate( c00_b, c01_b, c10_b, c11_b, dx, dy );
+ dst_ptr[dst_x] = rgb_to_pixel_masks( dst_dib, r, g, b );
+
+ float_x += src_inc_x;
+ }
+
+ dst_ptr += dst_dib->stride / 4;
+ float_y += src_inc_y;
+ }
+}
+
+static void halftone_24( const dib_info *dst_dib, const struct bitblt_coords *dst,
+ const dib_info *src_dib, const struct bitblt_coords *src )
+{
+ int src_start_x, src_start_y, src_ptr_dy, dst_x, dst_y, x0, x1, y0, y1;
+ BYTE *dst_ptr, *src_ptr, *c00_ptr, *c01_ptr, *c10_ptr, *c11_ptr;
+ float src_inc_x, src_inc_y, float_x, float_y, dx, dy;
+ BYTE c00_r, c01_r, c10_r, c11_r;
+ BYTE c00_g, c01_g, c10_g, c11_g;
+ BYTE c00_b, c01_b, c10_b, c11_b;
+ RECT dst_rect, src_rect;
+ BYTE r, g, b;
+
+ calc_halftone_params( dst, src, &dst_rect, &src_rect, &src_start_x, &src_start_y, &src_inc_x,
+ &src_inc_y );
+
+ float_y = src_start_y;
+ dst_ptr = get_pixel_ptr_24( dst_dib, dst_rect.left, dst_rect.top );
+ for (dst_y = 0; dst_y < dst_rect.bottom - dst_rect.top; ++dst_y)
+ {
+ float_y = clampf( float_y, src_rect.top, src_rect.bottom - 1 );
+ y0 = float_y;
+ y1 = clamp( y0 + 1, src_rect.top, src_rect.bottom - 1 );
+ dy = float_y - y0;
+
+ float_x = src_start_x;
+ src_ptr = get_pixel_ptr_24( src_dib, 0, y0 );
+ src_ptr_dy = (y1 - y0) * src_dib->stride;
+ for (dst_x = 0; dst_x < dst_rect.right - dst_rect.left; ++dst_x)
+ {
+ float_x = clampf( float_x, src_rect.left, src_rect.right - 1 );
+ x0 = float_x;
+ x1 = clamp( x0 + 1, src_rect.left, src_rect.right - 1 );
+ dx = float_x - x0;
+
+ c00_ptr = src_ptr + x0 * 3;
+ c01_ptr = src_ptr + x1 * 3;
+ c10_ptr = c00_ptr + src_ptr_dy;
+ c11_ptr = c01_ptr + src_ptr_dy;
+ c00_b = c00_ptr[0];
+ c01_b = c01_ptr[0];
+ c10_b = c10_ptr[0];
+ c11_b = c11_ptr[0];
+ c00_g = c00_ptr[1];
+ c01_g = c01_ptr[1];
+ c10_g = c10_ptr[1];
+ c11_g = c11_ptr[1];
+ c00_r = c00_ptr[2];
+ c01_r = c01_ptr[2];
+ c10_r = c10_ptr[2];
+ c11_r = c11_ptr[2];
+ r = bilinear_interpolate( c00_r, c01_r, c10_r, c11_r, dx, dy );
+ g = bilinear_interpolate( c00_g, c01_g, c10_g, c11_g, dx, dy );
+ b = bilinear_interpolate( c00_b, c01_b, c10_b, c11_b, dx, dy );
+ dst_ptr[dst_x * 3] = b;
+ dst_ptr[dst_x * 3 + 1] = g;
+ dst_ptr[dst_x * 3 + 2] = r;
+
+ float_x += src_inc_x;
+ }
+
+ dst_ptr += dst_dib->stride;
+ float_y += src_inc_y;
+ }
+}
+
+static void halftone_555( const dib_info *dst_dib, const struct bitblt_coords *dst,
+ const dib_info *src_dib, const struct bitblt_coords *src )
+{
+ int src_start_x, src_start_y, src_ptr_dy, dst_x, dst_y, x0, x1, y0, y1;
+ WORD *dst_ptr, *src_ptr, *c00_ptr, *c01_ptr, *c10_ptr, *c11_ptr;
+ float src_inc_x, src_inc_y, float_x, float_y, dx, dy;
+ BYTE c00_r, c01_r, c10_r, c11_r;
+ BYTE c00_g, c01_g, c10_g, c11_g;
+ BYTE c00_b, c01_b, c10_b, c11_b;
+ RECT dst_rect, src_rect;
+ BYTE r, g, b;
+
+ calc_halftone_params( dst, src, &dst_rect, &src_rect, &src_start_x, &src_start_y, &src_inc_x,
+ &src_inc_y );
+
+ float_y = src_start_y;
+ dst_ptr = get_pixel_ptr_16( dst_dib, dst_rect.left, dst_rect.top );
+ for (dst_y = 0; dst_y < dst_rect.bottom - dst_rect.top; ++dst_y)
+ {
+ float_y = clampf( float_y, src_rect.top, src_rect.bottom - 1 );
+ y0 = float_y;
+ y1 = clamp( y0 + 1, src_rect.top, src_rect.bottom - 1 );
+ dy = float_y - y0;
+
+ float_x = src_start_x;
+ src_ptr = get_pixel_ptr_16( src_dib, 0, y0 );
+ src_ptr_dy = (y1 - y0) * src_dib->stride / 2;
+ for (dst_x = 0; dst_x < dst_rect.right - dst_rect.left; ++dst_x)
+ {
+ float_x = clampf( float_x, src_rect.left, src_rect.right - 1 );
+ x0 = float_x;
+ x1 = clamp( x0 + 1, src_rect.left, src_rect.right - 1 );
+ dx = float_x - x0;
+
+ c00_ptr = src_ptr + x0;
+ c01_ptr = src_ptr + x1;
+ c10_ptr = c00_ptr + src_ptr_dy;
+ c11_ptr = c01_ptr + src_ptr_dy;
+ c00_r = ((*c00_ptr >> 7) & 0xf8) | ((*c00_ptr >> 12) & 0x07);
+ c01_r = ((*c01_ptr >> 7) & 0xf8) | ((*c01_ptr >> 12) & 0x07);
+ c10_r = ((*c10_ptr >> 7) & 0xf8) | ((*c10_ptr >> 12) & 0x07);
+ c11_r = ((*c11_ptr >> 7) & 0xf8) | ((*c11_ptr >> 12) & 0x07);
+ c00_g = ((*c00_ptr >> 2) & 0xf8) | ((*c00_ptr >> 7) & 0x07);
+ c01_g = ((*c01_ptr >> 2) & 0xf8) | ((*c01_ptr >> 7) & 0x07);
+ c10_g = ((*c10_ptr >> 2) & 0xf8) | ((*c10_ptr >> 7) & 0x07);
+ c11_g = ((*c11_ptr >> 2) & 0xf8) | ((*c11_ptr >> 7) & 0x07);
+ c00_b = ((*c00_ptr << 3) & 0xf8) | ((*c00_ptr >> 2) & 0x07);
+ c01_b = ((*c01_ptr << 3) & 0xf8) | ((*c01_ptr >> 2) & 0x07);
+ c10_b = ((*c10_ptr << 3) & 0xf8) | ((*c10_ptr >> 2) & 0x07);
+ c11_b = ((*c11_ptr << 3) & 0xf8) | ((*c11_ptr >> 2) & 0x07);
+ r = bilinear_interpolate( c00_r, c01_r, c10_r, c11_r, dx, dy );
+ g = bilinear_interpolate( c00_g, c01_g, c10_g, c11_g, dx, dy );
+ b = bilinear_interpolate( c00_b, c01_b, c10_b, c11_b, dx, dy );
+ dst_ptr[dst_x] = ((r << 7) & 0x7c00) | ((g << 2) & 0x03e0) | ((b >> 3) & 0x001f);
+
+ float_x += src_inc_x;
+ }
+
+ dst_ptr += dst_dib->stride / 2;
+ float_y += src_inc_y;
+ }
+}
+
+static void halftone_16( const dib_info *dst_dib, const struct bitblt_coords *dst,
+ const dib_info *src_dib, const struct bitblt_coords *src )
+{
+ int src_start_x, src_start_y, src_ptr_dy, dst_x, dst_y, x0, x1, y0, y1;
+ WORD *dst_ptr, *src_ptr, *c00_ptr, *c01_ptr, *c10_ptr, *c11_ptr;
+ float src_inc_x, src_inc_y, float_x, float_y, dx, dy;
+ BYTE c00_r, c01_r, c10_r, c11_r;
+ BYTE c00_g, c01_g, c10_g, c11_g;
+ BYTE c00_b, c01_b, c10_b, c11_b;
+ RECT dst_rect, src_rect;
+ BYTE r, g, b;
+
+ calc_halftone_params( dst, src, &dst_rect, &src_rect, &src_start_x, &src_start_y, &src_inc_x,
+ &src_inc_y );
+
+ float_y = src_start_y;
+ dst_ptr = get_pixel_ptr_16( dst_dib, dst_rect.left, dst_rect.top );
+ for (dst_y = 0; dst_y < dst_rect.bottom - dst_rect.top; ++dst_y)
+ {
+ float_y = clampf( float_y, src_rect.top, src_rect.bottom - 1 );
+ y0 = float_y;
+ y1 = clamp( y0 + 1, src_rect.top, src_rect.bottom - 1 );
+ dy = float_y - y0;
+
+ float_x = src_start_x;
+ src_ptr = get_pixel_ptr_16( src_dib, 0, y0 );
+ src_ptr_dy = (y1 - y0) * src_dib->stride / 2;
+ for (dst_x = 0; dst_x < dst_rect.right - dst_rect.left; ++dst_x)
+ {
+ float_x = clampf( float_x, src_rect.left, src_rect.right - 1 );
+ x0 = float_x;
+ x1 = clamp( x0 + 1, src_rect.left, src_rect.right - 1 );
+ dx = float_x - x0;
+
+ c00_ptr = src_ptr + x0;
+ c01_ptr = src_ptr + x1;
+ c10_ptr = c00_ptr + src_ptr_dy;
+ c11_ptr = c01_ptr + src_ptr_dy;
+ c00_r = get_field( *c00_ptr, src_dib->red_shift, src_dib->red_len );
+ c01_r = get_field( *c01_ptr, src_dib->red_shift, src_dib->red_len );
+ c10_r = get_field( *c10_ptr, src_dib->red_shift, src_dib->red_len );
+ c11_r = get_field( *c11_ptr, src_dib->red_shift, src_dib->red_len );
+ c00_g = get_field( *c00_ptr, src_dib->green_shift, src_dib->green_len );
+ c01_g = get_field( *c01_ptr, src_dib->green_shift, src_dib->green_len );
+ c10_g = get_field( *c10_ptr, src_dib->green_shift, src_dib->green_len );
+ c11_g = get_field( *c11_ptr, src_dib->green_shift, src_dib->green_len );
+ c00_b = get_field( *c00_ptr, src_dib->blue_shift, src_dib->blue_len );
+ c01_b = get_field( *c01_ptr, src_dib->blue_shift, src_dib->blue_len );
+ c10_b = get_field( *c10_ptr, src_dib->blue_shift, src_dib->blue_len );
+ c11_b = get_field( *c11_ptr, src_dib->blue_shift, src_dib->blue_len );
+ r = bilinear_interpolate( c00_r, c01_r, c10_r, c11_r, dx, dy );
+ g = bilinear_interpolate( c00_g, c01_g, c10_g, c11_g, dx, dy );
+ b = bilinear_interpolate( c00_b, c01_b, c10_b, c11_b, dx, dy );
+ dst_ptr[dst_x] = rgb_to_pixel_masks( dst_dib, r, g, b );
+
+ float_x += src_inc_x;
+ }
+
+ dst_ptr += dst_dib->stride / 2;
+ float_y += src_inc_y;
+ }
+}
+
+static void halftone_8( const dib_info *dst_dib, const struct bitblt_coords *dst,
+ const dib_info *src_dib, const struct bitblt_coords *src )
+{
+ int src_start_x, src_start_y, src_ptr_dy, dst_x, dst_y, x0, x1, y0, y1;
+ BYTE *dst_ptr, *src_ptr, *c00_ptr, *c01_ptr, *c10_ptr, *c11_ptr;
+ RGBQUAD c00_rgb, c01_rgb, c10_rgb, c11_rgb, zero_rgb = {0};
+ float src_inc_x, src_inc_y, float_x, float_y, dx, dy;
+ const RGBQUAD *src_clr_table;
+ RECT dst_rect, src_rect;
+ BYTE r, g, b;
+
+ calc_halftone_params( dst, src, &dst_rect, &src_rect, &src_start_x, &src_start_y, &src_inc_x,
+ &src_inc_y );
+
+ float_y = src_start_y;
+ src_clr_table = get_dib_color_table( src_dib );
+ dst_ptr = get_pixel_ptr_8( dst_dib, dst_rect.left, dst_rect.top );
+ for (dst_y = 0; dst_y < dst_rect.bottom - dst_rect.top; ++dst_y)
+ {
+ float_y = clampf( float_y, src_rect.top, src_rect.bottom - 1 );
+ y0 = float_y;
+ y1 = clamp( y0 + 1, src_rect.top, src_rect.bottom - 1 );
+ dy = float_y - y0;
+
+ float_x = src_start_x;
+ src_ptr = get_pixel_ptr_8( src_dib, 0, y0 );
+ src_ptr_dy = (y1 - y0) * src_dib->stride;
+ for (dst_x = 0; dst_x < dst_rect.right - dst_rect.left; ++dst_x)
+ {
+ float_x = clampf( float_x, src_rect.left, src_rect.right - 1 );
+ x0 = float_x;
+ x1 = clamp( x0 + 1, src_rect.left, src_rect.right - 1 );
+ dx = float_x - x0;
+
+ c00_ptr = src_ptr + x0;
+ c01_ptr = src_ptr + x1;
+ c10_ptr = c00_ptr + src_ptr_dy;
+ c11_ptr = c01_ptr + src_ptr_dy;
+ if (src_clr_table)
+ {
+ c00_rgb = *c00_ptr < src_dib->color_table_size ? src_clr_table[*c00_ptr] : zero_rgb;
+ c01_rgb = *c01_ptr < src_dib->color_table_size ? src_clr_table[*c01_ptr] : zero_rgb;
+ c10_rgb = *c10_ptr < src_dib->color_table_size ? src_clr_table[*c10_ptr] : zero_rgb;
+ c11_rgb = *c11_ptr < src_dib->color_table_size ? src_clr_table[*c11_ptr] : zero_rgb;
+ r = bilinear_interpolate( c00_rgb.rgbRed, c01_rgb.rgbRed, c10_rgb.rgbRed, c11_rgb.rgbRed, dx, dy );
+ g = bilinear_interpolate( c00_rgb.rgbGreen, c01_rgb.rgbGreen, c10_rgb.rgbGreen, c11_rgb.rgbGreen, dx, dy );
+ b = bilinear_interpolate( c00_rgb.rgbBlue, c01_rgb.rgbBlue, c10_rgb.rgbBlue, c11_rgb.rgbBlue, dx, dy );
+ }
+ else
+ {
+ r = 0;
+ g = 0;
+ b = 0;
+ }
+ dst_ptr[dst_x] = rgb_to_pixel_colortable( dst_dib, r, g, b );
+
+ float_x += src_inc_x;
+ }
+
+ dst_ptr += dst_dib->stride;
+ float_y += src_inc_y;
+ }
+}
+
+static void halftone_4( const dib_info *dst_dib, const struct bitblt_coords *dst,
+ const dib_info *src_dib, const struct bitblt_coords *src )
+{
+ BYTE *dst_col_ptr, *dst_ptr, *src_ptr, *c00_ptr, *c01_ptr, *c10_ptr, *c11_ptr;
+ int src_start_x, src_start_y, src_ptr_dy, dst_x, dst_y, x0, x1, y0, y1;
+ RGBQUAD c00_rgb, c01_rgb, c10_rgb, c11_rgb, zero_rgb = {0};
+ float src_inc_x, src_inc_y, float_x, float_y, dx, dy;
+ BYTE r, g, b, val, c00, c01, c10, c11;
+ const RGBQUAD *src_clr_table;
+ RECT dst_rect, src_rect;
+
+ calc_halftone_params( dst, src, &dst_rect, &src_rect, &src_start_x, &src_start_y, &src_inc_x,
+ &src_inc_y );
+
+ float_y = src_start_y;
+ src_clr_table = get_dib_color_table( src_dib );
+ dst_col_ptr = (BYTE *)dst_dib->bits.ptr + (dst_dib->rect.top + dst_rect.top) * dst_dib->stride;
+ for (dst_y = 0; dst_y < dst_rect.bottom - dst_rect.top; ++dst_y)
+ {
+ float_y = clampf( float_y, src_rect.top, src_rect.bottom - 1 );
+ y0 = float_y;
+ y1 = clamp( y0 + 1, src_rect.top, src_rect.bottom - 1 );
+ dy = float_y - y0;
+
+ float_x = src_start_x;
+ src_ptr = (BYTE *)src_dib->bits.ptr + (src_dib->rect.top + y0) * src_dib->stride;
+ src_ptr_dy = (y1 - y0) * src_dib->stride;
+ for (dst_x = dst_rect.left; dst_x < dst_rect.right; ++dst_x)
+ {
+ float_x = clampf( float_x, src_rect.left, src_rect.right - 1 );
+ x0 = float_x;
+ x1 = clamp( x0 + 1, src_rect.left, src_rect.right - 1 );
+ dx = float_x - x0;
+
+ c00_ptr = src_ptr + (src_dib->rect.left + x0) / 2;
+ c01_ptr = src_ptr + (src_dib->rect.left + x1) / 2;
+ c10_ptr = c00_ptr + src_ptr_dy;
+ c11_ptr = c01_ptr + src_ptr_dy;
+ if ((src_dib->rect.left + x0) & 1)
+ {
+ c00 = *c00_ptr & 0x0f;
+ c10 = *c10_ptr & 0x0f;
+ }
+ else
+ {
+ c00 = (*c00_ptr >> 4) & 0x0f;
+ c10 = (*c10_ptr >> 4) & 0x0f;
+ }
+ if ((src_dib->rect.left + x1) & 1)
+ {
+ c01 = *c01_ptr & 0x0f;
+ c11 = *c11_ptr & 0x0f;
+ }
+ else
+ {
+ c01 = (*c01_ptr >> 4) & 0x0f;
+ c11 = (*c11_ptr >> 4) & 0x0f;
+ }
+
+ if (src_clr_table)
+ {
+ c00_rgb = c00 < src_dib->color_table_size ? src_clr_table[c00] : zero_rgb;
+ c01_rgb = c01 < src_dib->color_table_size ? src_clr_table[c01] : zero_rgb;
+ c10_rgb = c10 < src_dib->color_table_size ? src_clr_table[c10] : zero_rgb;
+ c11_rgb = c11 < src_dib->color_table_size ? src_clr_table[c11] : zero_rgb;
+ r = bilinear_interpolate( c00_rgb.rgbRed, c01_rgb.rgbRed, c10_rgb.rgbRed, c11_rgb.rgbRed, dx, dy );
+ g = bilinear_interpolate( c00_rgb.rgbGreen, c01_rgb.rgbGreen, c10_rgb.rgbGreen, c11_rgb.rgbGreen, dx, dy );
+ b = bilinear_interpolate( c00_rgb.rgbBlue, c01_rgb.rgbBlue, c10_rgb.rgbBlue, c11_rgb.rgbBlue, dx, dy );
+ }
+ else
+ {
+ r = 0;
+ g = 0;
+ b = 0;
+ }
+
+ dst_ptr = dst_col_ptr + (dst_dib->rect.left + dst_x) / 2;
+ val = rgb_to_pixel_colortable( dst_dib, r, g, b );
+ if ((dst_x + dst_dib->rect.left) & 1)
+ *dst_ptr = (val & 0x0f) | (*dst_ptr & 0xf0);
+ else
+ *dst_ptr = (val << 4) & 0xf0;
+
+ float_x += src_inc_x;
+ }
+
+ dst_col_ptr += dst_dib->stride;
+ float_y += src_inc_y;
+ }
+}
+
+static void halftone_1( const dib_info *dst_dib, const struct bitblt_coords *dst,
+ const dib_info *src_dib, const struct bitblt_coords *src )
+{
+ int src_start_x, src_start_y, src_ptr_dy, dst_x, dst_y, x0, x1, y0, y1, bit_pos;
+ BYTE *dst_col_ptr, *dst_ptr, *src_ptr, *c00_ptr, *c01_ptr, *c10_ptr, *c11_ptr;
+ RGBQUAD c00_rgb, c01_rgb, c10_rgb, c11_rgb, zero_rgb = {0};
+ float src_inc_x, src_inc_y, float_x, float_y, dx, dy;
+ BYTE r, g, b, val, c00, c01, c10, c11;
+ const RGBQUAD *src_clr_table;
+ RECT dst_rect, src_rect;
+ RGBQUAD bg_entry;
+ DWORD bg_pixel;
+
+ calc_halftone_params( dst, src, &dst_rect, &src_rect, &src_start_x, &src_start_y, &src_inc_x,
+ &src_inc_y );
+
+ float_y = src_start_y;
+ bg_entry = *get_dib_color_table( dst_dib );
+ src_clr_table = get_dib_color_table( src_dib );
+ dst_col_ptr = (BYTE *)dst_dib->bits.ptr + (dst_dib->rect.top + dst_rect.top) * dst_dib->stride;
+ for (dst_y = dst_rect.top; dst_y < dst_rect.bottom; ++dst_y)
+ {
+ float_y = clampf( float_y, src_rect.top, src_rect.bottom - 1 );
+ y0 = float_y;
+ y1 = clamp( y0 + 1, src_rect.top, src_rect.bottom - 1 );
+ dy = float_y - y0;
+
+ float_x = src_start_x;
+ src_ptr = (BYTE *)src_dib->bits.ptr + (src_dib->rect.top + y0) * src_dib->stride;
+ src_ptr_dy = (y1 - y0) * src_dib->stride;
+ for (dst_x = dst_rect.left; dst_x < dst_rect.right; ++dst_x)
+ {
+ float_x = clampf( float_x, src_rect.left, src_rect.right - 1 );
+ x0 = float_x;
+ x1 = clamp( x0 + 1, src_rect.left, src_rect.right - 1 );
+ dx = float_x - x0;
+
+ c00_ptr = src_ptr + (src_dib->rect.left + x0) / 8;
+ c01_ptr = src_ptr + (src_dib->rect.left + x1) / 8;
+ c10_ptr = c00_ptr + src_ptr_dy;
+ c11_ptr = c01_ptr + src_ptr_dy;
+ c00 = (*c00_ptr & pixel_masks_1[(src_dib->rect.left + x0) & 7]) ? 1 : 0;
+ c01 = (*c01_ptr & pixel_masks_1[(src_dib->rect.left + x1) & 7]) ? 1 : 0;
+ c10 = (*c10_ptr & pixel_masks_1[(src_dib->rect.left + x0) & 7]) ? 1 : 0;
+ c11 = (*c11_ptr & pixel_masks_1[(src_dib->rect.left + x1) & 7]) ? 1 : 0;
+
+ if (src_clr_table)
+ {
+ c00_rgb = c00 < src_dib->color_table_size ? src_clr_table[c00] : zero_rgb;
+ c01_rgb = c01 < src_dib->color_table_size ? src_clr_table[c01] : zero_rgb;
+ c10_rgb = c10 < src_dib->color_table_size ? src_clr_table[c10] : zero_rgb;
+ c11_rgb = c11 < src_dib->color_table_size ? src_clr_table[c11] : zero_rgb;
+ r = bilinear_interpolate( c00_rgb.rgbRed, c01_rgb.rgbRed, c10_rgb.rgbRed, c11_rgb.rgbRed, dx, dy );
+ g = bilinear_interpolate( c00_rgb.rgbGreen, c01_rgb.rgbGreen, c10_rgb.rgbGreen, c11_rgb.rgbGreen, dx, dy );
+ b = bilinear_interpolate( c00_rgb.rgbBlue, c01_rgb.rgbBlue, c10_rgb.rgbBlue, c11_rgb.rgbBlue, dx, dy );
+ }
+ else
+ {
+ r = 0;
+ g = 0;
+ b = 0;
+ }
+
+ dst_ptr = dst_col_ptr + (dst_dib->rect.left + dst_x) / 8;
+ bit_pos = (dst_x + dst_dib->rect.left) & 7;
+ bg_pixel = FILTER_DIBINDEX(bg_entry, RGB(bg_entry.rgbRed, bg_entry.rgbGreen, bg_entry.rgbBlue));
+ val = rgb_to_pixel_mono( dst_dib, FALSE, dst_x, dst_y, RGB(r, g, b), bg_pixel, r, g, b );
+ if (bit_pos == 0)
+ *dst_ptr = 0;
+ *dst_ptr = (*dst_ptr & ~pixel_masks_1[bit_pos]) | (val & pixel_masks_1[bit_pos]);
+
+ float_x += src_inc_x;
+ }
+
+ dst_col_ptr += dst_dib->stride;
+ float_y += src_inc_y;
+ }
+}
+
+static void halftone_null( const dib_info *dst_dib, const struct bitblt_coords *dst,
+ const dib_info *src_dib, const struct bitblt_coords *src )
+{}
+
const primitive_funcs funcs_8888 =
{
solid_rects_32,
@@ -7448,7 +8050,8 @@ const primitive_funcs funcs_8888 =
create_rop_masks_32,
create_dither_masks_null,
stretch_row_32,
- shrink_row_32
+ shrink_row_32,
+ halftone_888
};
const primitive_funcs funcs_32 =
@@ -7469,7 +8072,8 @@ const primitive_funcs funcs_32 =
create_rop_masks_32,
create_dither_masks_null,
stretch_row_32,
- shrink_row_32
+ shrink_row_32,
+ halftone_32
};
const primitive_funcs funcs_24 =
@@ -7490,7 +8094,8 @@ const primitive_funcs funcs_24 =
create_rop_masks_24,
create_dither_masks_null,
stretch_row_24,
- shrink_row_24
+ shrink_row_24,
+ halftone_24
};
const primitive_funcs funcs_555 =
@@ -7511,7 +8116,8 @@ const primitive_funcs funcs_555 =
create_rop_masks_16,
create_dither_masks_null,
stretch_row_16,
- shrink_row_16
+ shrink_row_16,
+ halftone_555
};
const primitive_funcs funcs_16 =
@@ -7532,7 +8138,8 @@ const primitive_funcs funcs_16 =
create_rop_masks_16,
create_dither_masks_null,
stretch_row_16,
- shrink_row_16
+ shrink_row_16,
+ halftone_16
};
const primitive_funcs funcs_8 =
@@ -7553,7 +8160,8 @@ const primitive_funcs funcs_8 =
create_rop_masks_8,
create_dither_masks_8,
stretch_row_8,
- shrink_row_8
+ shrink_row_8,
+ halftone_8
};
const primitive_funcs funcs_4 =
@@ -7574,7 +8182,8 @@ const primitive_funcs funcs_4 =
create_rop_masks_4,
create_dither_masks_4,
stretch_row_4,
- shrink_row_4
+ shrink_row_4,
+ halftone_4
};
const primitive_funcs funcs_1 =
@@ -7595,7 +8204,8 @@ const primitive_funcs funcs_1 =
create_rop_masks_1,
create_dither_masks_1,
stretch_row_1,
- shrink_row_1
+ shrink_row_1,
+ halftone_1
};
const primitive_funcs funcs_null =
@@ -7616,5 +8226,6 @@ const primitive_funcs funcs_null =
create_rop_masks_null,
create_dither_masks_null,
stretch_row_null,
- shrink_row_null
+ shrink_row_null,
+ halftone_null
};
--
2.30.2
3
2
14 Jun '21
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
I'm not sure the tests should be in tests/dib.c. The framework in dib.c hashes results and compares them.
I don't think that's going to help us figuring out the exact HALFTONE algorithm details with the results
being hashes. Also, the tests that succeed have all input pixels has the same value. So if I only add the
tests that succeed, it provides little value. The tests here are mostly for helping figuring out the
algorithm in the future. Since the actual Wine implementation in the previous patch uses a different approach.
It doesn't reproduce identical results. So if you feel that such tests are not necessary, you can drop this.
dlls/gdi32/tests/bitmap.c | 1136 +++++++++++++++++++++++++++++++++++++
1 file changed, 1136 insertions(+)
diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c
index fe3482671b2..c28dde8159b 100644
--- a/dlls/gdi32/tests/bitmap.c
+++ b/dlls/gdi32/tests/bitmap.c
@@ -57,6 +57,29 @@ static inline int get_dib_image_size( const BITMAPINFO *info )
* abs( info->bmiHeader.biHeight );
}
+static void dump_bits(int bpp, int width, const BYTE *expected, const BYTE *result, int size,
+ const char *comment)
+{
+ int i, stride;
+
+ stride = get_dib_stride(width, bpp);
+ printf("%s expected:\n", comment);
+ for (i = 0; i < size; i++)
+ {
+ printf("%02x ", expected[i]);
+ if ((i + 1) % stride == 0)
+ printf("\n");
+ }
+ printf("\n%s got:\n", comment);
+ for (i = 0; i < size; i++)
+ {
+ printf("%02x ", result[i]);
+ if ((i + 1) % stride == 0)
+ printf("\n");
+ }
+ printf("\n");
+}
+
static void test_bitmap_info(HBITMAP hbm, INT expected_depth, const BITMAPINFOHEADER *bmih)
{
BITMAP bm;
@@ -3426,6 +3449,1118 @@ static void test_StretchBlt(void)
DeleteDC(hdcScreen);
}
+static void test_StretchBlt_HALFTONE(void)
+{
+#define PAD_ZERO 0x00,
+
+ /* Same dimension */
+ /* 1x1 -> 1x1 */
+ static const unsigned char test_bits_0[] =
+ {
+ 0xff, 0x7f, 0x00,
+ };
+ static const unsigned char expected_bits_0[] =
+ {
+ 0xff, 0x7f, 0x00,
+ };
+
+ /* Shrink horizontally */
+ /* 2x1 -> 1x1 */
+ /* 0xff / 2 = 0x7f.8, (0xff + 1) / 2 = 0x80 */
+ static const unsigned char test_bits_1[] =
+ {
+ 0xff, 0xff, 0xff, 0x00, 0x01, 0x00,
+ };
+ static const unsigned char expected_bits_1[] =
+ {
+ 0x7f, 0x80, 0x7f,
+ };
+ static const unsigned char test_bits_2[] =
+ {
+ 0x00, 0x01, 0x00, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char expected_bits_2[] =
+ {
+ 0x7f, 0x80, 0x7f,
+ };
+
+ /* 3x1 -> 1x1 */
+ /* 0xff / 3 = 0x55 */
+ static const unsigned char test_bits_3[] =
+ {
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+ static const unsigned char expected_bits_3[] =
+ {
+ 0x54, 0x54, 0x54,
+ };
+ static const unsigned char test_bits_4[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ };
+ static const unsigned char expected_bits_4[] =
+ {
+ 0x55, 0x55, 0x55,
+ };
+ static const unsigned char test_bits_5[] =
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char expected_bits_5[] =
+ {
+ 0x55, 0x55, 0x55,
+ };
+ /* 0xff * 2 / 3 = 0xaa */
+ static const unsigned char test_bits_6[] =
+ {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ };
+ static const unsigned char expected_bits_6[] =
+ {
+ 0xa9, 0xa9, 0xa9,
+ };
+ static const unsigned char test_bits_7[] =
+ {
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char expected_bits_7[] =
+ {
+ 0xa9, 0xa9, 0xa9,
+ };
+ static const unsigned char test_bits_8[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char expected_bits_8[] =
+ {
+ 0xaa, 0xaa, 0xaa,
+ };
+ static const unsigned char test_bits_9[] =
+ {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char expected_bits_9[] =
+ {
+ 0xff, 0xff, 0xff,
+ };
+
+ /* 4x1 -> 1x1 */
+ /* 0xff * 3 / 4 = 0xbf.4 */
+ static const unsigned char test_bits_10[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char expected_bits_10[] =
+ {
+ 0xbf, 0xbf, 0xbf,
+ };
+
+ /* 5x1 -> 1x1 */
+ /* 0xff * 4 / 5 = 0xcc */
+ static const unsigned char test_bits_11[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char expected_bits_11[] =
+ {
+ 0xcc, 0xcc, 0xcc,
+ };
+
+ /* Shrink horizontally with non-integer ratio */
+ /* 3x1 -> 2x1 */
+ static const unsigned char test_bits_12[] =
+ {
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+ static const unsigned char expected_bits_12[] =
+ {
+ 0xd4, 0xd4, 0xd4, 0x00, 0x00, 0x00,
+ };
+ static const unsigned char test_bits_13[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ };
+ static const unsigned char expected_bits_13[] =
+ {
+ 0x55, 0x55, 0x55, 0x54, 0x54, 0x54,
+ };
+ static const unsigned char test_bits_14[] =
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char expected_bits_14[] =
+ {
+ 0x00, 0x00, 0x00, 0xd4, 0xd4, 0xd4,
+ };
+ static const unsigned char test_bits_15[] =
+ {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ };
+ static const unsigned char expected_bits_15[] =
+ {
+ 0xff, 0xff, 0xff, 0x2a, 0x2a, 0x2a,
+ };
+ static const unsigned char test_bits_16[] =
+ {
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char expected_bits_16[] =
+ {
+ 0xa9, 0xa9, 0xa9, 0xaa, 0xaa, 0xaa,
+ };
+ static const unsigned char test_bits_17[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char expected_bits_17[] =
+ {
+ 0x2a, 0x2a, 0x2a, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char test_bits_18[] =
+ {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char expected_bits_18[] =
+ {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+
+ /* 4x1 -> 3x1 */
+ static const unsigned char test_bits_19[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char expected_bits_19[] =
+ {
+ 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char test_bits_20[] =
+ {
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ };
+ static const unsigned char expected_bits_20[] =
+ {
+ 0xcf, 0xcf, 0xcf, 0x7f, 0x7f, 0x7f, 0x2f, 0x2f, 0x2f,
+ };
+ static const unsigned char test_bits_21[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char expected_bits_21[] =
+ {
+ 0x2f, 0x2f, 0x2f, 0x7f, 0x7f, 0x7f, 0xcf, 0xcf, 0xcf,
+ };
+ static const unsigned char test_bits_22[] =
+ {
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff
+ };
+ static const unsigned char expected_bits_22[] =
+ {
+ 0xef, 0xef, 0xef, 0x00, 0x00, 0x00, 0xef, 0xef, 0xef,
+ };
+ static const unsigned char test_bits_23[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ };
+ static const unsigned char expected_bits_23[] =
+ {
+ 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f,
+ };
+
+ /* 5x1 -> 3x1 */
+ static const unsigned char test_bits_24[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char expected_bits_24[] =
+ {
+ 0x3f, 0x3f, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char test_bits_25[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ };
+ static const unsigned char expected_bits_25[] =
+ {
+ 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x65, 0x65, 0x65,
+ };
+ static const unsigned char test_bits_26[] =
+ {
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char expected_bits_26[] =
+ {
+ 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x99, 0x99, 0x99,
+ };
+
+ /* Shrink vertically */
+ /* 1x2 -> 1x1 */
+ /* 0xff / 2 = 0x7f.8, (0xff + 1) / 2 = 0x80 */
+ static const unsigned char test_bits_27[] =
+ {
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x01, 0x00, PAD_ZERO
+ };
+ static const unsigned char expected_bits_27[] =
+ {
+ 0x7f, 0x80, 0x7f
+ };
+ static const unsigned char test_bits_28[] =
+ {
+ 0x00, 0x01, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char expected_bits_28[] =
+ {
+ 0x7f, 0x80, 0x7f
+ };
+
+ /* 1x3 -> 1x1 */
+ /* 0xff / 3 = 0x55 */
+ static const unsigned char test_bits_29[] =
+ {
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ };
+ static const unsigned char expected_bits_29[] =
+ {
+ 0x55, 0x55, 0x55,
+ };
+ static const unsigned char test_bits_30[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ };
+ static const unsigned char expected_bits_30[] =
+ {
+ 0x55, 0x55, 0x55,
+ };
+ static const unsigned char test_bits_31[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char expected_bits_31[] =
+ {
+ 0x54, 0x54, 0x54,
+ };
+ /* 0xff * 2 / 3 = 0xaa */
+ static const unsigned char test_bits_32[] =
+ {
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ };
+ static const unsigned char expected_bits_32[] =
+ {
+ 0xaa, 0xaa, 0xaa,
+ };
+ static const unsigned char test_bits_33[] =
+ {
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char expected_bits_33[] =
+ {
+ 0xa9, 0xa9, 0xa9,
+ };
+ static const unsigned char test_bits_34[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char expected_bits_34[] =
+ {
+ 0xa9, 0xa9, 0xa9,
+ };
+ static const unsigned char test_bits_35[] =
+ {
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char expected_bits_35[] =
+ {
+ 0xff, 0xff, 0xff,
+ };
+
+ /* 1x4 -> 1x1 */
+ /* 0xff * 3 / 4 = 0xbf.4 */
+ static const unsigned char test_bits_36[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char expected_bits_36[] =
+ {
+ 0xbf, 0xbf, 0xbf,
+ };
+
+ /* 1x5 -> 1x1 */
+ /* 0xff * 4 / 5 = 0xcc */
+ static const unsigned char test_bits_37[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char expected_bits_37[] =
+ {
+ 0xcb, 0xcb, 0xcb,
+ };
+
+ /* Shrink vertically with a non-integer ratio */
+ /* 3x1 -> 2x1 */
+ static const unsigned char test_bits_38[] =
+ {
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ };
+ static const unsigned char expected_bits_38[] =
+ {
+ 0xd4, 0xd4, 0xd4, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ };
+ static const unsigned char test_bits_39[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ };
+ static const unsigned char expected_bits_39[] =
+ {
+ 0x54, 0x54, 0x54, PAD_ZERO
+ 0x55, 0x55, 0x55, PAD_ZERO
+ };
+ static const unsigned char test_bits_40[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char expected_bits_40[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xd4, 0xd4, 0xd4, PAD_ZERO
+ };
+ static const unsigned char test_bits_41[] =
+ {
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ };
+ static const unsigned char expected_bits_41[] =
+ {
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x2a, 0x2a, 0x2a, PAD_ZERO
+ };
+ static const unsigned char test_bits_42[] =
+ {
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char expected_bits_42[] =
+ {
+ 0xaa, 0xaa, 0xaa, PAD_ZERO
+ 0xa9, 0xa9, 0xa9, PAD_ZERO
+ };
+ static const unsigned char test_bits_43[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char expected_bits_43[] =
+ {
+ 0x2a, 0x2a, 0x2a, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char test_bits_44[] =
+ {
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char expected_bits_44[] =
+ {
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+
+ /* 4x1 -> 3x1 */
+ static const unsigned char test_bits_45[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char expected_bits_45[] =
+ {
+ 0x0f, 0x0f, 0x0f, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char test_bits_46[] =
+ {
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ };
+ static const unsigned char expected_bits_46[] =
+ {
+ 0xcf, 0xcf, 0xcf, PAD_ZERO
+ 0x7f, 0x7f, 0x7f, PAD_ZERO
+ 0x2f, 0x2f, 0x2f, PAD_ZERO
+ };
+ static const unsigned char test_bits_47[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char expected_bits_47[] =
+ {
+ 0x2f, 0x2f, 0x2f, PAD_ZERO
+ 0x7f, 0x7f, 0x7f, PAD_ZERO
+ 0xcf, 0xcf, 0xcf, PAD_ZERO
+ };
+ static const unsigned char test_bits_48[] =
+ {
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char expected_bits_48[] =
+ {
+ 0xef, 0xef, 0xef, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xef, 0xef, 0xef, PAD_ZERO
+ };
+ static const unsigned char test_bits_49[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ };
+ static const unsigned char expected_bits_49[] =
+ {
+ 0x0f, 0x0f, 0x0f, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x0f, 0x0f, 0x0f, PAD_ZERO
+ };
+
+ /* 5x1 -> 3x1 */
+ static const unsigned char test_bits_50[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char expected_bits_50[] =
+ {
+ 0x3f, 0x3f, 0x3f, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char test_bits_51[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ };
+ static const unsigned char expected_bits_51[] =
+ {
+ 0x65, 0x65, 0x65, PAD_ZERO
+ 0x66, 0x66, 0x66, PAD_ZERO
+ 0x66, 0x66, 0x66, PAD_ZERO
+ };
+ static const unsigned char test_bits_52[] =
+ {
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char expected_bits_52[] =
+ {
+ 0x99, 0x99, 0x99, PAD_ZERO
+ 0x98, 0x98, 0x98, PAD_ZERO
+ 0x98, 0x98, 0x98, PAD_ZERO
+ };
+
+ /* Stretch horizontally */
+ /* 1x1 -> 2x1 */
+ static const unsigned char test_bits_53[] =
+ {
+ 0xff, 0xff, 0xff,
+ };
+ static const unsigned char expected_bits_53[] =
+ {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+ /* 2x1 -> 3x1 */
+ static const unsigned char test_bits_54[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char expected_bits_54[] =
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ };
+ /* 3x1 -> 4x1 */
+ static const unsigned char test_bits_55[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char expected_bits_55[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+ /* 4x1 -> 5x1 */
+ static const unsigned char test_bits_56[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char expected_bits_56[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+
+ /* Stretch vertically */
+ /* 1x1 -> 1x2 */
+ static const unsigned char test_bits_57[] =
+ {
+ 0xff, 0xff, 0xff,
+ };
+ static const unsigned char expected_bits_57[] =
+ {
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ /* 1x2 -> 1x3 */
+ static const unsigned char test_bits_58[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char expected_bits_58[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ /* 1x3 -> 1x4 */
+ static const unsigned char test_bits_59[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char expected_bits_59[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ /* 1x4 -> 1x5 */
+ static const unsigned char test_bits_60[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char expected_bits_60[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+
+ /* Shrink both horizontally and vertically*/
+ /* 2x2 -> 1x1 */
+ /* 0xff / 4 = 0x3f.c */
+ static const unsigned char test_bits_61[] =
+ {
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_61[] =
+ {
+ 0x40, 0x40, 0x40,
+ };
+ static const unsigned char test_bits_62[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, PAD_ZERO PAD_ZERO
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_62[] =
+ {
+ 0x40, 0x40, 0x40,
+ };
+ static const unsigned char test_bits_63[] =
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_63[] =
+ {
+ 0x40, 0x40, 0x40,
+ };
+ static const unsigned char test_bits_64[] =
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_64[] =
+ {
+ 0x40, 0x40, 0x40,
+ };
+ /* 0xff * 2 / 4 = 0x7f.8 */
+ static const unsigned char test_bits_65[] =
+ {
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_65[] =
+ {
+ 0x80, 0x80, 0x80,
+ };
+ static const unsigned char test_bits_66[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, PAD_ZERO PAD_ZERO
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_66[] =
+ {
+ 0x80, 0x80, 0x80,
+ };
+ static const unsigned char test_bits_67[] =
+ {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, PAD_ZERO PAD_ZERO
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_67[] =
+ {
+ 0xff, 0xff, 0xff,
+ };
+
+ /* Stretch horizontally and shrink vertically */
+ /* 2x2 -> 1x4 */
+ static const unsigned char test_bits_68[] =
+ {
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_68[] =
+ {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+ static const unsigned char test_bits_69[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, PAD_ZERO PAD_ZERO
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_69[] =
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+ };
+ static const unsigned char test_bits_70[] =
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_70[] =
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+ static const unsigned char test_bits_71[] =
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_71[] =
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ };
+ static const unsigned char test_bits_72[] =
+ {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, PAD_ZERO PAD_ZERO
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_72[] =
+ {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ };
+ static const unsigned char test_bits_73[] =
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_73[] =
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+ /* 0xff * 2 / 4 = 0x7f.8 */
+ static const unsigned char test_bits_74[] =
+ {
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_74[] =
+ {
+ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80
+ };
+ static const unsigned char test_bits_75[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, PAD_ZERO PAD_ZERO
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_75[] =
+ {
+ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80
+ };
+ static const unsigned char test_bits_76[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, PAD_ZERO PAD_ZERO
+ 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_76[] =
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+ };
+ /* 0xfe * 2 / 4 = 0x7f */
+ static const unsigned char test_bits_77[] =
+ {
+ 0x00, 0x00, 0x00, 0xfe, 0xfe, 0xfe, PAD_ZERO PAD_ZERO
+ 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_77[] =
+ {
+ 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f
+ };
+
+ /* Stretch vertically and shrink horizontally */
+ /* 2x2 -> 4x1 */
+ static const unsigned char test_bits_78[] =
+ {
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_78[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ };
+ static const unsigned char test_bits_79[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, PAD_ZERO PAD_ZERO
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_79[] =
+ {
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ };
+ static const unsigned char test_bits_80[] =
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_80[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ };
+ static const unsigned char test_bits_81[] =
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_81[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ static const unsigned char test_bits_82[] =
+ {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, PAD_ZERO PAD_ZERO
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_82[] =
+ {
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ };
+ static const unsigned char test_bits_83[] =
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_83[] =
+ {
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ };
+ /* 0xff * 2 / 4 = 0x7f.8 */
+ static const unsigned char test_bits_84[] =
+ {
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_84[] =
+ {
+ 0x80, 0x80, 0x80, PAD_ZERO
+ 0x80, 0x80, 0x80, PAD_ZERO
+ 0x80, 0x80, 0x80, PAD_ZERO
+ 0x80, 0x80, 0x80, PAD_ZERO
+ };
+ static const unsigned char test_bits_85[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, PAD_ZERO PAD_ZERO
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_85[] =
+ {
+ 0x80, 0x80, 0x80, PAD_ZERO
+ 0x80, 0x80, 0x80, PAD_ZERO
+ 0x80, 0x80, 0x80, PAD_ZERO
+ 0x80, 0x80, 0x80, PAD_ZERO
+ };
+ static const unsigned char test_bits_86[] =
+ {
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, PAD_ZERO PAD_ZERO
+ 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_86[] =
+ {
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0xff, 0xff, 0xff, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ 0x00, 0x00, 0x00, PAD_ZERO
+ };
+ /* 0xfe * 2 / 4 = 0x7f */
+ static const unsigned char test_bits_87[] =
+ {
+ 0x00, 0x00, 0x00, 0xfe, 0xfe, 0xfe, PAD_ZERO PAD_ZERO
+ 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00, PAD_ZERO PAD_ZERO
+ };
+ static const unsigned char expected_bits_87[] =
+ {
+ 0x7f, 0x7f, 0x7f, PAD_ZERO
+ 0x7f, 0x7f, 0x7f, PAD_ZERO
+ 0x7f, 0x7f, 0x7f, PAD_ZERO
+ 0x7f, 0x7f, 0x7f, PAD_ZERO
+ };
+
+#undef PAD_ZERO
+
+ static const struct
+ {
+ const unsigned char *src_bits;
+ size_t src_bits_size;
+ const unsigned char *dst_bits;
+ size_t dst_bits_size;
+ int bpp;
+ int src_width;
+ int src_height;
+ int dst_width;
+ int dst_height;
+ BOOL todo;
+ }
+ tests[] =
+ {
+#define BITS(x) test_bits_##x, sizeof(test_bits_##x), expected_bits_##x, sizeof(expected_bits_##x)
+
+ {BITS(0), 24, 1, 1, 1, 1},
+ {BITS(1), 24, 2, 1, 1, 1, TRUE},
+ {BITS(2), 24, 2, 1, 1, 1, TRUE},
+ {BITS(3), 24, 3, 1, 1, 1, TRUE},
+ {BITS(4), 24, 3, 1, 1, 1, TRUE},
+ {BITS(5), 24, 3, 1, 1, 1, TRUE},
+ {BITS(6), 24, 3, 1, 1, 1, TRUE},
+ {BITS(7), 24, 3, 1, 1, 1, TRUE},
+ {BITS(8), 24, 3, 1, 1, 1, TRUE},
+ {BITS(9), 24, 3, 1, 1, 1},
+ {BITS(10), 24, 4, 1, 1, 1, TRUE},
+ {BITS(11), 24, 5, 1, 1, 1, TRUE},
+ {BITS(12), 24, 3, 1, 2, 1, TRUE},
+ {BITS(13), 24, 3, 1, 2, 1, TRUE},
+ {BITS(14), 24, 3, 1, 2, 1, TRUE},
+ {BITS(15), 24, 3, 1, 2, 1, TRUE},
+ {BITS(16), 24, 3, 1, 2, 1, TRUE},
+ {BITS(17), 24, 3, 1, 2, 1, TRUE},
+ {BITS(18), 24, 3, 1, 2, 1},
+ {BITS(19), 24, 4, 1, 3, 1, TRUE},
+ {BITS(20), 24, 4, 1, 3, 1, TRUE},
+ {BITS(21), 24, 4, 1, 3, 1, TRUE},
+ {BITS(22), 24, 4, 1, 3, 1, TRUE},
+ {BITS(23), 24, 4, 1, 3, 1, TRUE},
+ {BITS(24), 24, 5, 1, 3, 1, TRUE},
+ {BITS(25), 24, 5, 1, 3, 1, TRUE},
+ {BITS(26), 24, 5, 1, 3, 1, TRUE},
+ {BITS(27), 24, 1, 2, 1, 1, TRUE},
+ {BITS(28), 24, 1, 2, 1, 1, TRUE},
+ {BITS(29), 24, 1, 3, 1, 1, TRUE},
+ {BITS(30), 24, 1, 3, 1, 1, TRUE},
+ {BITS(31), 24, 1, 3, 1, 1, TRUE},
+ {BITS(32), 24, 1, 3, 1, 1, TRUE},
+ {BITS(33), 24, 1, 3, 1, 1, TRUE},
+ {BITS(34), 24, 1, 3, 1, 1, TRUE},
+ {BITS(35), 24, 1, 3, 1, 1},
+ {BITS(36), 24, 1, 4, 1, 1, TRUE},
+ {BITS(37), 24, 1, 5, 1, 1, TRUE},
+ {BITS(38), 24, 1, 3, 1, 2, TRUE},
+ {BITS(39), 24, 1, 3, 1, 2, TRUE},
+ {BITS(40), 24, 1, 3, 1, 2, TRUE},
+ {BITS(41), 24, 1, 3, 1, 2, TRUE},
+ {BITS(42), 24, 1, 3, 1, 2, TRUE},
+ {BITS(43), 24, 1, 3, 1, 2, TRUE},
+ {BITS(44), 24, 1, 3, 1, 2},
+ {BITS(45), 24, 1, 4, 1, 3, TRUE},
+ {BITS(46), 24, 1, 4, 1, 3, TRUE},
+ {BITS(47), 24, 1, 4, 1, 3, TRUE},
+ {BITS(48), 24, 1, 4, 1, 3, TRUE},
+ {BITS(49), 24, 1, 4, 1, 3, TRUE},
+ {BITS(50), 24, 1, 5, 1, 3, TRUE},
+ {BITS(51), 24, 1, 5, 1, 3, TRUE},
+ {BITS(52), 24, 1, 5, 1, 3, TRUE},
+ {BITS(53), 24, 1, 1, 2, 1},
+ {BITS(54), 24, 2, 1, 3, 1, TRUE},
+ {BITS(55), 24, 3, 1, 4, 1, TRUE},
+ {BITS(56), 24, 4, 1, 5, 1, TRUE},
+ {BITS(57), 24, 1, 1, 1, 2},
+ {BITS(58), 24, 1, 2, 1, 3, TRUE},
+ {BITS(59), 24, 1, 3, 1, 4, TRUE},
+ {BITS(60), 24, 1, 4, 1, 5, TRUE},
+ {BITS(61), 24, 2, 2, 1, 1, TRUE},
+ {BITS(62), 24, 2, 2, 1, 1, TRUE},
+ {BITS(63), 24, 2, 2, 1, 1, TRUE},
+ {BITS(64), 24, 2, 2, 1, 1, TRUE},
+ {BITS(65), 24, 2, 2, 1, 1, TRUE},
+ {BITS(66), 24, 2, 2, 1, 1, TRUE},
+ {BITS(67), 24, 2, 2, 1, 1},
+ {BITS(68), 24, 2, 2, 4, 1, TRUE},
+ {BITS(69), 24, 2, 2, 4, 1, TRUE},
+ {BITS(70), 24, 2, 2, 4, 1, TRUE},
+ {BITS(71), 24, 2, 2, 4, 1, TRUE},
+ {BITS(72), 24, 2, 2, 4, 1, TRUE},
+ {BITS(73), 24, 2, 2, 4, 1, TRUE},
+ {BITS(74), 24, 2, 2, 4, 1, TRUE},
+ {BITS(75), 24, 2, 2, 4, 1, TRUE},
+ {BITS(76), 24, 2, 2, 4, 1, TRUE},
+ {BITS(77), 24, 2, 2, 4, 1, TRUE},
+ {BITS(78), 24, 2, 2, 1, 4, TRUE},
+ {BITS(79), 24, 2, 2, 1, 4, TRUE},
+ {BITS(80), 24, 2, 2, 1, 4, TRUE},
+ {BITS(81), 24, 2, 2, 1, 4, TRUE},
+ {BITS(82), 24, 2, 2, 1, 4, TRUE},
+ {BITS(83), 24, 2, 2, 1, 4, TRUE},
+ {BITS(84), 24, 2, 2, 1, 4, TRUE},
+ {BITS(85), 24, 2, 2, 1, 4, TRUE},
+ {BITS(86), 24, 2, 2, 1, 4, TRUE},
+ {BITS(87), 24, 2, 2, 1, 4, TRUE},
+
+#undef BITS
+ };
+
+ unsigned char bmi_buffer[FIELD_OFFSET(BITMAPINFO, bmiColors[256])];
+ HBITMAP src_bmp, dst_bmp, old_src_bmp, old_dst_bmp;
+ BITMAPINFO *bmi = (BITMAPINFO *)bmi_buffer;
+ unsigned char *src_bits, *dst_bits;
+ HDC dc, src_dc, dst_dc;
+ int i, ret;
+
+ dc = GetDC(0);
+
+ memset(&bmi_buffer, 0, sizeof(bmi_buffer));
+ bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmi->bmiHeader.biPlanes = 1;
+ bmi->bmiHeader.biCompression = BI_RGB;
+
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
+ {
+ winetest_push_context("Test %d", i);
+
+ bmi->bmiHeader.biBitCount = tests[i].bpp;
+ bmi->bmiHeader.biWidth = tests[i].src_width;
+ bmi->bmiHeader.biHeight = tests[i].src_height;
+ src_dc = CreateCompatibleDC(dc);
+ src_bmp = CreateDIBSection(src_dc, bmi, DIB_RGB_COLORS, (void **)&src_bits, NULL, 0);
+ ok(src_bmp && src_bits, "CreateDIBSection failed, error %u.\n", GetLastError());
+ memcpy(src_bits, tests[i].src_bits, tests[i].src_bits_size);
+ old_src_bmp = SelectObject(src_dc, src_bmp);
+
+ bmi->bmiHeader.biWidth = tests[i].dst_width;
+ bmi->bmiHeader.biHeight = tests[i].dst_height;
+ dst_dc = CreateCompatibleDC(dc);
+ dst_bmp = CreateDIBSection(dst_dc, bmi, DIB_RGB_COLORS, (void **)&dst_bits, NULL, 0);
+ ok(dst_bmp && dst_bits, "CreateDIBSection failed, error %u.\n", GetLastError());
+ old_dst_bmp = SelectObject(dst_dc, dst_bmp);
+
+ SetStretchBltMode(dst_dc, HALFTONE);
+ ret = GetStretchBltMode(dst_dc);
+ ok(ret == HALFTONE, "Expected mode %#x, got %#x\n", HALFTONE, ret);
+ ret = StretchBlt(dst_dc, 0, 0, tests[i].dst_width, tests[i].dst_height, src_dc, 0, 0,
+ tests[i].src_width, tests[i].src_height, SRCCOPY);
+ ok(ret, "StretchBlt failed, error %u.\n", GetLastError());
+
+ ret = memcmp(dst_bits, tests[i].dst_bits, tests[i].dst_bits_size);
+ todo_wine_if(tests[i].todo)
+ ok(!ret, "Bits mismatch.\n");
+ if (ret)
+ dump_bits(tests[i].bpp, tests[i].dst_width, tests[i].dst_bits, dst_bits,
+ tests[i].dst_bits_size, "StretchBlt_HALFTONE");
+
+ SelectObject(dst_dc, old_dst_bmp);
+ SelectObject(src_dc, old_src_bmp);
+ DeleteObject(dst_bmp);
+ DeleteObject(src_bmp);
+ DeleteDC(dst_dc);
+ DeleteDC(src_dc);
+
+ winetest_pop_context();
+ }
+
+ ReleaseDC(0, dc);
+}
+
static void check_StretchDIBits_pixel(HDC hdcDst, UINT32 *dstBuffer, UINT32 *srcBuffer,
DWORD dwRop, UINT32 expected, int line)
{
@@ -5963,6 +7098,7 @@ START_TEST(bitmap)
test_CreateBitmap();
test_BitBlt();
test_StretchBlt();
+ test_StretchBlt_HALFTONE();
test_StretchDIBits();
test_GdiAlphaBlend();
test_GdiGradientFill();
--
2.30.2
2
1
[PATCH 1/2] wined3d: Implement wined3d_deferred_context_update_sub_resource().
by Zebediah Figura 11 Jun '21
by Zebediah Figura 11 Jun '21
11 Jun '21
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/wined3d/cs.c | 37 +++++++++++++++++++++++++++++++++----
1 file changed, 33 insertions(+), 4 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 50a08334dab..e6f84134795 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -490,6 +490,7 @@ struct wined3d_cs_update_sub_resource
unsigned int sub_resource_idx;
struct wined3d_box box;
struct wined3d_sub_resource_data data;
+ /* If data.data is NULL, the structure is followed by the data in memory. */
};
struct wined3d_cs_add_dirty_texture_region
@@ -2597,6 +2598,7 @@ void wined3d_device_context_emit_blt_sub_resource(struct wined3d_device_context
static void wined3d_cs_exec_update_sub_resource(struct wined3d_cs *cs, const void *data)
{
const struct wined3d_cs_update_sub_resource *op = data;
+ const void *src_data = op->data.data ? op->data.data : (const BYTE *)(op + 1);
struct wined3d_resource *resource = op->resource;
const struct wined3d_box *box = &op->box;
unsigned int width, height, depth, level;
@@ -2617,7 +2619,7 @@ static void wined3d_cs_exec_update_sub_resource(struct wined3d_cs *cs, const voi
goto done;
}
- wined3d_buffer_upload_data(buffer, context, box, op->data.data);
+ wined3d_buffer_upload_data(buffer, context, box, src_data);
wined3d_buffer_invalidate_location(buffer, ~WINED3D_LOCATION_BUFFER);
goto done;
}
@@ -2630,7 +2632,7 @@ static void wined3d_cs_exec_update_sub_resource(struct wined3d_cs *cs, const voi
depth = wined3d_texture_get_level_depth(texture, level);
addr.buffer_object = 0;
- addr.addr = op->data.data;
+ addr.addr = src_data;
/* Only load the sub-resource for partial updates. */
if (!box->left && !box->top && !box->front
@@ -3375,8 +3377,35 @@ static void wined3d_deferred_context_update_sub_resource(struct wined3d_device_c
struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box,
const void *data, unsigned int row_pitch, unsigned int slice_pitch)
{
- FIXME("context %p, resource %p, sub_resource_idx %u, box %s, data %p, row_pitch %u, slice_pitch %u, stub!\n",
- context, resource, sub_resource_idx, debug_box(box), data, row_pitch, slice_pitch);
+ struct wined3d_cs_update_sub_resource *op;
+ size_t data_size;
+
+ if (resource->type == WINED3D_RTYPE_BUFFER)
+ {
+ data_size = box->right - box->left;
+ }
+ else
+ {
+ const struct wined3d_format *format = resource->format;
+
+ data_size = (box->back - box->front - 1) * slice_pitch
+ + ((box->bottom - box->top - 1) / format->block_height) * row_pitch
+ + ((box->right - box->left + format->block_width - 1) / format->block_width) * format->block_byte_count;
+ }
+
+ op = wined3d_device_context_require_space(context, sizeof(*op) + data_size, WINED3D_CS_QUEUE_DEFAULT);
+ op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE;
+ op->resource = resource;
+ op->sub_resource_idx = sub_resource_idx;
+ op->box = *box;
+ op->data.row_pitch = row_pitch;
+ op->data.slice_pitch = slice_pitch;
+ op->data.data = NULL;
+ memcpy(op + 1, data, data_size);
+
+ wined3d_device_context_acquire_resource(context, resource);
+
+ wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
}
static void wined3d_deferred_context_issue_query(struct wined3d_device_context *context,
--
2.30.2
5
14
10 Jun '21
To automatically put the compilation context in a failed state.
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
libs/vkd3d-shader/hlsl.c | 102 ++++++++++-----------
libs/vkd3d-shader/hlsl.h | 57 +++++++++---
libs/vkd3d-shader/hlsl.l | 5 +-
libs/vkd3d-shader/hlsl.y | 137 ++++++++++++++--------------
libs/vkd3d-shader/hlsl_codegen.c | 147 +++++++++++--------------------
5 files changed, 216 insertions(+), 232 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c
index e81efa2d..86ef1247 100644
--- a/libs/vkd3d-shader/hlsl.c
+++ b/libs/vkd3d-shader/hlsl.c
@@ -103,7 +103,7 @@ struct hlsl_type *hlsl_new_type(struct hlsl_ctx *ctx, const char *name, enum hls
{
struct hlsl_type *type;
- if (!(type = vkd3d_calloc(1, sizeof(*type))))
+ if (!(type = hlsl_alloc(ctx, sizeof(*type))))
return NULL;
type->name = name;
type->type = type_class;
@@ -149,7 +149,7 @@ struct hlsl_type *hlsl_new_struct_type(struct hlsl_ctx *ctx, const char *name, s
unsigned int reg_size = 0;
struct hlsl_type *type;
- if (!(type = vkd3d_calloc(1, sizeof(*type))))
+ if (!(type = hlsl_alloc(ctx, sizeof(*type))))
return NULL;
type->type = HLSL_CLASS_STRUCT;
type->base_type = HLSL_TYPE_VOID;
@@ -281,12 +281,12 @@ struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old, u
struct hlsl_struct_field *old_field, *field;
struct hlsl_type *type;
- if (!(type = vkd3d_calloc(1, sizeof(*type))))
+ if (!(type = hlsl_alloc(ctx, sizeof(*type))))
return NULL;
if (old->name)
{
- type->name = vkd3d_strdup(old->name);
+ type->name = hlsl_strdup(ctx, old->name);
if (!type->name)
{
vkd3d_free(type);
@@ -313,7 +313,7 @@ struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old, u
{
unsigned int reg_size = 0;
- if (!(type->e.elements = vkd3d_malloc(sizeof(*type->e.elements))))
+ if (!(type->e.elements = hlsl_alloc(ctx, sizeof(*type->e.elements))))
{
vkd3d_free((void *)type->name);
vkd3d_free(type);
@@ -322,7 +322,7 @@ struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old, u
list_init(type->e.elements);
LIST_FOR_EACH_ENTRY(old_field, old->e.elements, struct hlsl_struct_field, entry)
{
- if (!(field = vkd3d_calloc(1, sizeof(*field))))
+ if (!(field = hlsl_alloc(ctx, sizeof(*field))))
{
LIST_FOR_EACH_ENTRY_SAFE(field, old_field, type->e.elements, struct hlsl_struct_field, entry)
{
@@ -337,10 +337,10 @@ struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old, u
}
field->loc = old_field->loc;
field->type = hlsl_type_clone(ctx, old_field->type, default_majority);
- field->name = vkd3d_strdup(old_field->name);
+ field->name = hlsl_strdup(ctx, old_field->name);
if (old_field->semantic.name)
{
- field->semantic.name = vkd3d_strdup(old_field->semantic.name);
+ field->semantic.name = hlsl_strdup(ctx, old_field->semantic.name);
field->semantic.index = old_field->semantic.index;
}
field->reg_offset = reg_size;
@@ -373,30 +373,30 @@ bool hlsl_scope_add_type(struct hlsl_scope *scope, struct hlsl_type *type)
return true;
}
-struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ir_node *node, struct hlsl_type *type,
+struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ctx *ctx, struct hlsl_ir_node *node, struct hlsl_type *type,
struct vkd3d_shader_location *loc)
{
struct hlsl_ir_node *cast;
- cast = hlsl_new_unary_expr(HLSL_IR_UNOP_CAST, node, *loc);
+ cast = hlsl_new_unary_expr(ctx, HLSL_IR_UNOP_CAST, node, *loc);
if (cast)
cast->data_type = type;
return hlsl_ir_expr(cast);
}
-struct hlsl_ir_expr *hlsl_new_copy(struct hlsl_ir_node *node)
+struct hlsl_ir_expr *hlsl_new_copy(struct hlsl_ctx *ctx, struct hlsl_ir_node *node)
{
/* Use a cast to the same type as a makeshift identity expression. */
- return hlsl_new_cast(node, node->data_type, &node->loc);
+ return hlsl_new_cast(ctx, node, node->data_type, &node->loc);
}
-struct hlsl_ir_var *hlsl_new_var(const char *name, struct hlsl_type *type,
+struct hlsl_ir_var *hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type,
const struct vkd3d_shader_location loc, const struct hlsl_semantic *semantic, unsigned int modifiers,
const struct hlsl_reg_reservation *reg_reservation)
{
struct hlsl_ir_var *var;
- if (!(var = vkd3d_calloc(1, sizeof(*var))))
+ if (!(var = hlsl_alloc(ctx, sizeof(*var))))
return NULL;
var->name = name;
@@ -412,7 +412,7 @@ struct hlsl_ir_var *hlsl_new_var(const char *name, struct hlsl_type *type,
struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type,
const struct vkd3d_shader_location loc)
{
- struct hlsl_ir_var *var = hlsl_new_var(vkd3d_strdup(name), type, loc, NULL, 0, NULL);
+ struct hlsl_ir_var *var = hlsl_new_var(ctx, hlsl_strdup(ctx, name), type, loc, NULL, 0, NULL);
if (var)
list_add_tail(&ctx->globals->vars, &var->scope_entry);
@@ -424,7 +424,7 @@ static bool type_is_single_reg(const struct hlsl_type *type)
return type->type == HLSL_CLASS_SCALAR || type->type == HLSL_CLASS_VECTOR;
}
-struct hlsl_ir_store *hlsl_new_store(struct hlsl_ir_var *var, struct hlsl_ir_node *offset,
+struct hlsl_ir_store *hlsl_new_store(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, struct hlsl_ir_node *offset,
struct hlsl_ir_node *rhs, unsigned int writemask, struct vkd3d_shader_location loc)
{
struct hlsl_ir_store *store;
@@ -432,7 +432,7 @@ struct hlsl_ir_store *hlsl_new_store(struct hlsl_ir_var *var, struct hlsl_ir_nod
if (!writemask && type_is_single_reg(rhs->data_type))
writemask = (1 << rhs->data_type->dimx) - 1;
- if (!(store = vkd3d_malloc(sizeof(*store))))
+ if (!(store = hlsl_alloc(ctx, sizeof(*store))))
return NULL;
init_node(&store->node, HLSL_IR_STORE, NULL, loc);
@@ -443,9 +443,9 @@ struct hlsl_ir_store *hlsl_new_store(struct hlsl_ir_var *var, struct hlsl_ir_nod
return store;
}
-struct hlsl_ir_store *hlsl_new_simple_store(struct hlsl_ir_var *lhs, struct hlsl_ir_node *rhs)
+struct hlsl_ir_store *hlsl_new_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir_var *lhs, struct hlsl_ir_node *rhs)
{
- return hlsl_new_store(lhs, NULL, rhs, 0, rhs->loc);
+ return hlsl_new_store(ctx, lhs, NULL, rhs, 0, rhs->loc);
}
struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
@@ -453,19 +453,19 @@ struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned i
{
struct hlsl_ir_constant *c;
- if (!(c = vkd3d_malloc(sizeof(*c))))
+ if (!(c = hlsl_alloc(ctx, sizeof(*c))))
return NULL;
init_node(&c->node, HLSL_IR_CONSTANT, ctx->builtin_types.scalar[HLSL_TYPE_UINT], loc);
c->value.u[0] = n;
return c;
}
-struct hlsl_ir_node *hlsl_new_unary_expr(enum hlsl_ir_expr_op op,
+struct hlsl_ir_node *hlsl_new_unary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op,
struct hlsl_ir_node *arg, struct vkd3d_shader_location loc)
{
struct hlsl_ir_expr *expr;
- if (!(expr = vkd3d_calloc(1, sizeof(*expr))))
+ if (!(expr = hlsl_alloc(ctx, sizeof(*expr))))
return NULL;
init_node(&expr->node, HLSL_IR_EXPR, arg->data_type, loc);
expr->op = op;
@@ -473,13 +473,14 @@ struct hlsl_ir_node *hlsl_new_unary_expr(enum hlsl_ir_expr_op op,
return &expr->node;
}
-struct hlsl_ir_node *hlsl_new_binary_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2)
+struct hlsl_ir_node *hlsl_new_binary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op,
+ struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2)
{
struct hlsl_ir_expr *expr;
assert(hlsl_types_are_equal(arg1->data_type, arg2->data_type));
- if (!(expr = vkd3d_calloc(1, sizeof(*expr))))
+ if (!(expr = hlsl_alloc(ctx, sizeof(*expr))))
return NULL;
init_node(&expr->node, HLSL_IR_EXPR, arg1->data_type, arg1->loc);
expr->op = op;
@@ -488,11 +489,11 @@ struct hlsl_ir_node *hlsl_new_binary_expr(enum hlsl_ir_expr_op op, struct hlsl_i
return &expr->node;
}
-struct hlsl_ir_if *hlsl_new_if(struct hlsl_ir_node *condition, struct vkd3d_shader_location loc)
+struct hlsl_ir_if *hlsl_new_if(struct hlsl_ctx *ctx, struct hlsl_ir_node *condition, struct vkd3d_shader_location loc)
{
struct hlsl_ir_if *iff;
- if (!(iff = vkd3d_malloc(sizeof(*iff))))
+ if (!(iff = hlsl_alloc(ctx, sizeof(*iff))))
return NULL;
init_node(&iff->node, HLSL_IR_IF, NULL, loc);
hlsl_src_from_node(&iff->condition, condition);
@@ -501,12 +502,12 @@ struct hlsl_ir_if *hlsl_new_if(struct hlsl_ir_node *condition, struct vkd3d_shad
return iff;
}
-struct hlsl_ir_load *hlsl_new_load(struct hlsl_ir_var *var, struct hlsl_ir_node *offset,
+struct hlsl_ir_load *hlsl_new_load(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, struct hlsl_ir_node *offset,
struct hlsl_type *type, const struct vkd3d_shader_location loc)
{
struct hlsl_ir_load *load;
- if (!(load = vkd3d_calloc(1, sizeof(*load))))
+ if (!(load = hlsl_alloc(ctx, sizeof(*load))))
return NULL;
init_node(&load->node, HLSL_IR_LOAD, type, loc);
load->src.var = var;
@@ -514,9 +515,10 @@ struct hlsl_ir_load *hlsl_new_load(struct hlsl_ir_var *var, struct hlsl_ir_node
return load;
}
-struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ir_var *var, const struct vkd3d_shader_location loc)
+struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ctx *ctx, struct hlsl_ir_var *var,
+ const struct vkd3d_shader_location loc)
{
- return hlsl_new_load(var, NULL, var->data_type, loc);
+ return hlsl_new_load(ctx, var, NULL, var->data_type, loc);
}
struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned int components,
@@ -524,7 +526,7 @@ struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned
{
struct hlsl_ir_swizzle *swizzle;
- if (!(swizzle = vkd3d_malloc(sizeof(*swizzle))))
+ if (!(swizzle = hlsl_alloc(ctx, sizeof(*swizzle))))
return NULL;
init_node(&swizzle->node, HLSL_IR_SWIZZLE,
hlsl_new_type(ctx, NULL, HLSL_CLASS_VECTOR, val->data_type->base_type, components, 1), *loc);
@@ -533,22 +535,22 @@ struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned
return swizzle;
}
-struct hlsl_ir_jump *hlsl_new_jump(enum hlsl_ir_jump_type type, struct vkd3d_shader_location loc)
+struct hlsl_ir_jump *hlsl_new_jump(struct hlsl_ctx *ctx, enum hlsl_ir_jump_type type, struct vkd3d_shader_location loc)
{
struct hlsl_ir_jump *jump;
- if (!(jump = vkd3d_malloc(sizeof(*jump))))
+ if (!(jump = hlsl_alloc(ctx, sizeof(*jump))))
return NULL;
init_node(&jump->node, HLSL_IR_JUMP, NULL, loc);
jump->type = type;
return jump;
}
-struct hlsl_ir_loop *hlsl_new_loop(struct vkd3d_shader_location loc)
+struct hlsl_ir_loop *hlsl_new_loop(struct hlsl_ctx *ctx, struct vkd3d_shader_location loc)
{
struct hlsl_ir_loop *loop;
- if (!(loop = vkd3d_calloc(1, sizeof(*loop))))
+ if (!(loop = hlsl_alloc(ctx, sizeof(*loop))))
return NULL;
init_node(&loop->node, HLSL_IR_LOOP, NULL, loc);
list_init(&loop->body);
@@ -565,7 +567,7 @@ struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hl
{
struct hlsl_ir_function_decl *decl;
- if (!(decl = vkd3d_calloc(1, sizeof(*decl))))
+ if (!(decl = hlsl_alloc(ctx, sizeof(*decl))))
return NULL;
decl->return_type = return_type;
decl->parameters = parameters;
@@ -577,7 +579,7 @@ struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hl
char name[28];
sprintf(name, "<retval-%p>", decl);
- if (!(return_var = hlsl_new_var(vkd3d_strdup(name), return_type, loc, semantic, 0, NULL)))
+ if (!(return_var = hlsl_new_var(ctx, hlsl_strdup(ctx, name), return_type, loc, semantic, 0, NULL)))
{
vkd3d_free(decl);
return NULL;
@@ -609,7 +611,7 @@ void hlsl_push_scope(struct hlsl_ctx *ctx)
{
struct hlsl_scope *new_scope;
- if (!(new_scope = vkd3d_malloc(sizeof(*new_scope))))
+ if (!(new_scope = hlsl_alloc(ctx, sizeof(*new_scope))))
return;
TRACE("Pushing a new scope.\n");
list_init(&new_scope->vars);
@@ -1333,12 +1335,12 @@ static void free_function_rb(struct rb_entry *entry, void *context)
free_function(RB_ENTRY_VALUE(entry, struct hlsl_ir_function, entry));
}
-void hlsl_add_function(struct rb_tree *funcs, char *name, struct hlsl_ir_function_decl *decl, bool intrinsic)
+void hlsl_add_function(struct hlsl_ctx *ctx, char *name, struct hlsl_ir_function_decl *decl, bool intrinsic)
{
struct hlsl_ir_function *func;
struct rb_entry *func_entry, *old_entry;
- func_entry = rb_get(funcs, name);
+ func_entry = rb_get(&ctx->functions, name);
if (func_entry)
{
func = RB_ENTRY_VALUE(func_entry, struct hlsl_ir_function, entry);
@@ -1372,13 +1374,13 @@ void hlsl_add_function(struct rb_tree *funcs, char *name, struct hlsl_ir_functio
vkd3d_free(name);
return;
}
- func = vkd3d_malloc(sizeof(*func));
+ func = hlsl_alloc(ctx, sizeof(*func));
func->name = name;
rb_init(&func->overloads, compare_function_decl_rb);
decl->func = func;
rb_put(&func->overloads, decl->parameters, &decl->entry);
func->intrinsic = intrinsic;
- rb_put(funcs, func->name, &func->entry);
+ rb_put(&ctx->functions, func->name, &func->entry);
}
static const struct hlsl_profile_info *get_target_info(const char *target)
@@ -1517,20 +1519,20 @@ static void declare_predefined_types(struct hlsl_ctx *ctx)
for (x = 1; x <= 4; ++x)
{
sprintf(name, "%s%ux%u", names[bt], y, x);
- type = hlsl_new_type(ctx, vkd3d_strdup(name), HLSL_CLASS_MATRIX, bt, x, y);
+ type = hlsl_new_type(ctx, hlsl_strdup(ctx, name), HLSL_CLASS_MATRIX, bt, x, y);
hlsl_scope_add_type(ctx->globals, type);
if (y == 1)
{
sprintf(name, "%s%u", names[bt], x);
- type = hlsl_new_type(ctx, vkd3d_strdup(name), HLSL_CLASS_VECTOR, bt, x, y);
+ type = hlsl_new_type(ctx, hlsl_strdup(ctx, name), HLSL_CLASS_VECTOR, bt, x, y);
hlsl_scope_add_type(ctx->globals, type);
ctx->builtin_types.vector[bt][x - 1] = type;
if (x == 1)
{
sprintf(name, "%s", names[bt]);
- type = hlsl_new_type(ctx, vkd3d_strdup(name), HLSL_CLASS_SCALAR, bt, x, y);
+ type = hlsl_new_type(ctx, hlsl_strdup(ctx, name), HLSL_CLASS_SCALAR, bt, x, y);
hlsl_scope_add_type(ctx->globals, type);
ctx->builtin_types.scalar[bt] = type;
}
@@ -1541,16 +1543,16 @@ static void declare_predefined_types(struct hlsl_ctx *ctx)
for (bt = 0; bt <= HLSL_SAMPLER_DIM_MAX; ++bt)
{
- type = hlsl_new_type(ctx, vkd3d_strdup(sampler_names[bt]), HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1);
+ type = hlsl_new_type(ctx, hlsl_strdup(ctx, sampler_names[bt]), HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1);
type->sampler_dim = bt;
ctx->builtin_types.sampler[bt] = type;
}
- ctx->builtin_types.Void = hlsl_new_type(ctx, vkd3d_strdup("void"), HLSL_CLASS_OBJECT, HLSL_TYPE_VOID, 1, 1);
+ ctx->builtin_types.Void = hlsl_new_type(ctx, hlsl_strdup(ctx, "void"), HLSL_CLASS_OBJECT, HLSL_TYPE_VOID, 1, 1);
for (i = 0; i < ARRAY_SIZE(effect_types); ++i)
{
- type = hlsl_new_type(ctx, vkd3d_strdup(effect_types[i].name), effect_types[i].class,
+ type = hlsl_new_type(ctx, hlsl_strdup(ctx, effect_types[i].name), effect_types[i].class,
effect_types[i].base_type, effect_types[i].dimx, effect_types[i].dimy);
hlsl_scope_add_type(ctx->globals, type);
}
@@ -1565,9 +1567,9 @@ static bool hlsl_ctx_init(struct hlsl_ctx *ctx, const struct hlsl_profile_info *
ctx->message_context = message_context;
- if (!(ctx->source_files = vkd3d_malloc(sizeof(*ctx->source_files))))
+ if (!(ctx->source_files = hlsl_alloc(ctx, sizeof(*ctx->source_files))))
return false;
- if (!(ctx->source_files[0] = vkd3d_strdup("")))
+ if (!(ctx->source_files[0] = hlsl_strdup(ctx, "")))
{
vkd3d_free(ctx->source_files);
return false;
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
index 9081ef37..3e7d2445 100644
--- a/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d-shader/hlsl.h
@@ -539,6 +539,34 @@ static inline void hlsl_src_remove(struct hlsl_src *src)
src->node = NULL;
}
+static inline void *hlsl_alloc(struct hlsl_ctx *ctx, size_t size)
+{
+ void *ptr = vkd3d_calloc(1, size);
+
+ if (!ptr)
+ ctx->failed = true;
+ return ptr;
+}
+
+static inline char *hlsl_strdup(struct hlsl_ctx *ctx, const char *string)
+{
+ char *ptr = vkd3d_strdup(string);
+
+ if (!ptr)
+ ctx->failed = true;
+ return ptr;
+}
+
+static inline bool hlsl_array_reserve(struct hlsl_ctx *ctx, void **elements,
+ size_t *capacity, size_t element_count, size_t element_size)
+{
+ bool ret = vkd3d_array_reserve(elements, capacity, element_count, element_size);
+
+ if (!ret)
+ ctx->failed = true;
+ return ret;
+}
+
const char *debug_hlsl_type(const struct hlsl_type *type) DECLSPEC_HIDDEN;
const char *debug_hlsl_writemask(unsigned int writemask) DECLSPEC_HIDDEN;
@@ -548,7 +576,7 @@ struct vkd3d_string_buffer *hlsl_modifiers_to_string(struct vkd3d_string_buffer_
unsigned int modifiers) DECLSPEC_HIDDEN;
const char *hlsl_node_type_to_string(enum hlsl_ir_node_type type) DECLSPEC_HIDDEN;
-void hlsl_add_function(struct rb_tree *funcs, char *name, struct hlsl_ir_function_decl *decl,
+void hlsl_add_function(struct hlsl_ctx *ctx, char *name, struct hlsl_ir_function_decl *decl,
bool intrinsic) DECLSPEC_HIDDEN;
bool hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, bool local_var) DECLSPEC_HIDDEN;
@@ -569,22 +597,24 @@ struct hlsl_ir_var *hlsl_get_var(struct hlsl_scope *scope, const char *name) DEC
struct hlsl_type *hlsl_new_array_type(struct hlsl_ctx *ctx, struct hlsl_type *basic_type,
unsigned int array_size) DECLSPEC_HIDDEN;
-struct hlsl_ir_node *hlsl_new_binary_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1,
+struct hlsl_ir_node *hlsl_new_binary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1,
struct hlsl_ir_node *arg2) DECLSPEC_HIDDEN;
-struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ir_node *node, struct hlsl_type *type,
+struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ctx *ctx, struct hlsl_ir_node *node, struct hlsl_type *type,
struct vkd3d_shader_location *loc) DECLSPEC_HIDDEN;
-struct hlsl_ir_expr *hlsl_new_copy(struct hlsl_ir_node *node) DECLSPEC_HIDDEN;
+struct hlsl_ir_expr *hlsl_new_copy(struct hlsl_ctx *ctx, struct hlsl_ir_node *node) DECLSPEC_HIDDEN;
struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hlsl_type *return_type,
struct list *parameters, const struct hlsl_semantic *semantic,
struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
-struct hlsl_ir_if *hlsl_new_if(struct hlsl_ir_node *condition, struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
-struct hlsl_ir_jump *hlsl_new_jump(enum hlsl_ir_jump_type type, struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
-struct hlsl_ir_load *hlsl_new_load(struct hlsl_ir_var *var, struct hlsl_ir_node *offset, struct hlsl_type *type,
+struct hlsl_ir_if *hlsl_new_if(struct hlsl_ctx *ctx, struct hlsl_ir_node *condition,
+ struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
+struct hlsl_ir_jump *hlsl_new_jump(struct hlsl_ctx *ctx, enum hlsl_ir_jump_type type,
struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
-struct hlsl_ir_loop *hlsl_new_loop(struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
-struct hlsl_ir_store *hlsl_new_simple_store(struct hlsl_ir_var *lhs,
+struct hlsl_ir_load *hlsl_new_load(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, struct hlsl_ir_node *offset,
+ struct hlsl_type *type, struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
+struct hlsl_ir_loop *hlsl_new_loop(struct hlsl_ctx *ctx, struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
+struct hlsl_ir_store *hlsl_new_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir_var *lhs,
struct hlsl_ir_node *rhs) DECLSPEC_HIDDEN;
-struct hlsl_ir_store *hlsl_new_store(struct hlsl_ir_var *var, struct hlsl_ir_node *offset,
+struct hlsl_ir_store *hlsl_new_store(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, struct hlsl_ir_node *offset,
struct hlsl_ir_node *rhs, unsigned int writemask, struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
struct hlsl_type *hlsl_new_struct_type(struct hlsl_ctx *ctx, const char *name, struct list *fields) DECLSPEC_HIDDEN;
struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned int components,
@@ -595,12 +625,13 @@ struct hlsl_type *hlsl_new_type(struct hlsl_ctx *ctx, const char *name, enum hls
enum hlsl_base_type base_type, unsigned dimx, unsigned dimy) DECLSPEC_HIDDEN;
struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
const struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
-struct hlsl_ir_node *hlsl_new_unary_expr(enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg,
+struct hlsl_ir_node *hlsl_new_unary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg,
struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
-struct hlsl_ir_var *hlsl_new_var(const char *name, struct hlsl_type *type,
+struct hlsl_ir_var *hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type,
const struct vkd3d_shader_location loc, const struct hlsl_semantic *semantic, unsigned int modifiers,
const struct hlsl_reg_reservation *reg_reservation) DECLSPEC_HIDDEN;
-struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ir_var *var, const struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
+struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ctx *ctx, struct hlsl_ir_var *var,
+ const struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, enum vkd3d_shader_error error,
const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5) DECLSPEC_HIDDEN;
diff --git a/libs/vkd3d-shader/hlsl.l b/libs/vkd3d-shader/hlsl.l
index cee98ea5..f8ff2830 100644
--- a/libs/vkd3d-shader/hlsl.l
+++ b/libs/vkd3d-shader/hlsl.l
@@ -170,7 +170,7 @@ row_major {return KW_ROW_MAJOR; }
{IDENTIFIER} {
struct hlsl_ctx *ctx = yyget_extra(yyscanner);
- yylval->name = vkd3d_strdup(yytext);
+ yylval->name = hlsl_strdup(ctx, yytext);
if (hlsl_get_var(ctx->cur_scope, yytext) || hlsl_get_function(ctx, yytext))
return VAR_IDENTIFIER;
else if (hlsl_get_type(ctx->cur_scope, yytext, true))
@@ -248,7 +248,8 @@ row_major {return KW_ROW_MAJOR; }
return PRE_LINE;
}
<pp_line>{STRING} {
- char *string = vkd3d_strdup(yytext + 1);
+ struct hlsl_ctx *ctx = yyget_extra(yyscanner);
+ char *string = hlsl_strdup(ctx, yytext + 1);
BEGIN(pp_ignore);
string[strlen(string) - 1] = 0;
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index bcb1c207..52544c43 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -127,11 +127,11 @@ static struct hlsl_ir_node *node_from_list(struct list *list)
return LIST_ENTRY(list_tail(list), struct hlsl_ir_node, entry);
}
-static struct list *make_empty_list(void)
+static struct list *make_empty_list(struct hlsl_ctx *ctx)
{
struct list *list;
- if ((list = vkd3d_malloc(sizeof(*list))))
+ if ((list = hlsl_alloc(ctx, sizeof(*list))))
list_init(list);
return list;
}
@@ -286,7 +286,7 @@ static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct
hlsl_warning(ctx, *loc, VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION, "Implicit truncation of %s type.",
src_type->type == HLSL_CLASS_VECTOR ? "vector" : "matrix");
- if (!(cast = hlsl_new_cast(node, dst_type, loc)))
+ if (!(cast = hlsl_new_cast(ctx, node, dst_type, loc)))
return NULL;
list_add_tail(instrs, &cast->node.entry);
return &cast->node;
@@ -313,7 +313,7 @@ static DWORD add_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, DWORD mod, con
return modifiers | mod;
}
-static bool append_conditional_break(struct list *cond_list)
+static bool append_conditional_break(struct hlsl_ctx *ctx, struct list *cond_list)
{
struct hlsl_ir_node *condition, *not;
struct hlsl_ir_jump *jump;
@@ -324,15 +324,15 @@ static bool append_conditional_break(struct list *cond_list)
return true;
condition = node_from_list(cond_list);
- if (!(not = hlsl_new_unary_expr(HLSL_IR_UNOP_LOGIC_NOT, condition, condition->loc)))
+ if (!(not = hlsl_new_unary_expr(ctx, HLSL_IR_UNOP_LOGIC_NOT, condition, condition->loc)))
return false;
list_add_tail(cond_list, ¬->entry);
- if (!(iff = hlsl_new_if(not, condition->loc)))
+ if (!(iff = hlsl_new_if(ctx, not, condition->loc)))
return false;
list_add_tail(cond_list, &iff->node.entry);
- if (!(jump = hlsl_new_jump(HLSL_IR_JUMP_BREAK, condition->loc)))
+ if (!(jump = hlsl_new_jump(ctx, HLSL_IR_JUMP_BREAK, condition->loc)))
return false;
list_add_head(&iff->then_instrs, &jump->node.entry);
return true;
@@ -345,24 +345,24 @@ enum loop_type
LOOP_DO_WHILE
};
-static struct list *create_loop(enum loop_type type, struct list *init, struct list *cond,
+static struct list *create_loop(struct hlsl_ctx *ctx, enum loop_type type, struct list *init, struct list *cond,
struct list *iter, struct list *body, struct vkd3d_shader_location loc)
{
struct list *list = NULL;
struct hlsl_ir_loop *loop = NULL;
struct hlsl_ir_if *cond_jump = NULL;
- if (!(list = make_empty_list()))
+ if (!(list = make_empty_list(ctx)))
goto oom;
if (init)
list_move_head(list, init);
- if (!(loop = hlsl_new_loop(loc)))
+ if (!(loop = hlsl_new_loop(ctx, loc)))
goto oom;
list_add_tail(list, &loop->node.entry);
- if (!append_conditional_break(cond))
+ if (!append_conditional_break(ctx, cond))
goto oom;
if (type != LOOP_DO_WHILE)
@@ -504,7 +504,7 @@ static struct hlsl_ir_jump *add_return(struct hlsl_ctx *ctx, struct list *instrs
if (!(return_value = add_implicit_conversion(ctx, instrs, return_value, return_type, &loc)))
return NULL;
- if (!(store = hlsl_new_simple_store(ctx->cur_function->return_var, return_value)))
+ if (!(store = hlsl_new_simple_store(ctx, ctx->cur_function->return_var, return_value)))
return NULL;
list_add_after(&return_value->entry, &store->node.entry);
}
@@ -514,7 +514,7 @@ static struct hlsl_ir_jump *add_return(struct hlsl_ctx *ctx, struct list *instrs
return NULL;
}
- if (!(jump = hlsl_new_jump(HLSL_IR_JUMP_RETURN, loc)))
+ if (!(jump = hlsl_new_jump(ctx, HLSL_IR_JUMP_RETURN, loc)))
return NULL;
list_add_tail(instrs, &jump->node.entry);
@@ -535,7 +535,7 @@ static struct hlsl_ir_load *add_load(struct hlsl_ctx *ctx, struct list *instrs,
var = src->var;
if (src->offset.node)
{
- if (!(add = hlsl_new_binary_expr(HLSL_IR_BINOP_ADD, src->offset.node, offset)))
+ if (!(add = hlsl_new_binary_expr(ctx, HLSL_IR_BINOP_ADD, src->offset.node, offset)))
return NULL;
list_add_tail(instrs, &add->entry);
offset = add;
@@ -550,13 +550,13 @@ static struct hlsl_ir_load *add_load(struct hlsl_ctx *ctx, struct list *instrs,
if (!(var = hlsl_new_synthetic_var(ctx, name, var_node->data_type, var_node->loc)))
return NULL;
- if (!(store = hlsl_new_simple_store(var, var_node)))
+ if (!(store = hlsl_new_simple_store(ctx, var, var_node)))
return NULL;
list_add_tail(instrs, &store->node.entry);
}
- if (!(load = hlsl_new_load(var, offset, data_type, loc)))
+ if (!(load = hlsl_new_load(ctx, var, offset, data_type, loc)))
return NULL;
list_add_tail(instrs, &load->node.entry);
return load;
@@ -604,7 +604,7 @@ static struct hlsl_ir_load *add_array_load(struct hlsl_ctx *ctx, struct list *in
if (!(c = hlsl_new_uint_constant(ctx, data_type->reg_size * 4, loc)))
return NULL;
list_add_tail(instrs, &c->node.entry);
- if (!(mul = hlsl_new_binary_expr(HLSL_IR_BINOP_MUL, index, &c->node)))
+ if (!(mul = hlsl_new_binary_expr(ctx, HLSL_IR_BINOP_MUL, index, &c->node)))
return NULL;
list_add_tail(instrs, &mul->entry);
index = mul;
@@ -676,13 +676,13 @@ static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *ty
if (type->type == HLSL_CLASS_MATRIX)
assert(type->modifiers & HLSL_MODIFIERS_MAJORITY_MASK);
- if (!(list = make_empty_list()))
+ if (!(list = make_empty_list(ctx)))
return NULL;
LIST_FOR_EACH_ENTRY_SAFE(v, v_next, fields, struct parse_variable_def, entry)
{
unsigned int i;
- if (!(field = vkd3d_calloc(1, sizeof(*field))))
+ if (!(field = hlsl_alloc(ctx, sizeof(*field))))
{
vkd3d_free(v);
return list;
@@ -767,7 +767,7 @@ static bool add_func_parameter(struct hlsl_ctx *ctx, struct list *list,
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"Parameter '%s' is declared as both \"out\" and \"uniform\".", param->name);
- if (!(var = hlsl_new_var(param->name, param->type, loc, ¶m->semantic, param->modifiers, param->reg_reservation)))
+ if (!(var = hlsl_new_var(ctx, param->name, param->type, loc, ¶m->semantic, param->modifiers, param->reg_reservation)))
return false;
var->is_param = 1;
@@ -780,7 +780,7 @@ static bool add_func_parameter(struct hlsl_ctx *ctx, struct list *list,
return true;
}
-static struct hlsl_reg_reservation *parse_reg_reservation(const char *reg_string)
+static struct hlsl_reg_reservation *parse_reg_reservation(struct hlsl_ctx *ctx, const char *reg_string)
{
enum vkd3d_shader_register_type type;
struct hlsl_reg_reservation *reg_res;
@@ -811,7 +811,7 @@ static struct hlsl_reg_reservation *parse_reg_reservation(const char *reg_string
return NULL;
}
- if (!(reg_res = vkd3d_malloc(sizeof(*reg_res))))
+ if (!(reg_res = hlsl_alloc(ctx, sizeof(*reg_res))))
return NULL;
reg_res->type = type;
reg_res->regnum = regnum;
@@ -841,11 +841,11 @@ static const struct hlsl_ir_function_decl *get_overloaded_func(struct rb_tree *f
return NULL;
}
-static struct list *make_list(struct hlsl_ir_node *node)
+static struct list *make_list(struct hlsl_ctx *ctx, struct hlsl_ir_node *node)
{
struct list *list;
- if (!(list = make_empty_list()))
+ if (!(list = make_empty_list(ctx)))
{
hlsl_free_instr(node);
return NULL;
@@ -1112,13 +1112,13 @@ static struct hlsl_ir_expr *add_expr(struct hlsl_ctx *ctx, struct list *instrs,
"Implicit truncation of %s type.",
operands[i]->data_type->type == HLSL_CLASS_VECTOR ? "vector" : "matrix");
- if (!(cast = hlsl_new_cast(operands[i], type, &operands[i]->loc)))
+ if (!(cast = hlsl_new_cast(ctx, operands[i], type, &operands[i]->loc)))
return NULL;
list_add_after(&operands[i]->entry, &cast->node.entry);
operands[i] = &cast->node;
}
- if (!(expr = vkd3d_calloc(1, sizeof(*expr))))
+ if (!(expr = hlsl_alloc(ctx, sizeof(*expr))))
return NULL;
init_node(&expr->node, HLSL_IR_EXPR, type, *loc);
expr->op = op;
@@ -1229,7 +1229,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
return NULL;
}
- if (!(store = vkd3d_malloc(sizeof(*store))))
+ if (!(store = hlsl_alloc(ctx, sizeof(*store))))
return NULL;
while (lhs->type != HLSL_IR_LOAD)
@@ -1283,7 +1283,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
/* Don't use the instruction itself as a source, as this makes structure
* splitting easier. Instead copy it here. Since we retrieve sources from
* the last instruction in the list, we do need to copy. */
- if (!(copy = hlsl_new_copy(rhs)))
+ if (!(copy = hlsl_new_copy(ctx, rhs)))
return NULL;
list_add_tail(instrs, ©->node.entry);
return ©->node;
@@ -1310,7 +1310,7 @@ static bool add_increment(struct hlsl_ctx *ctx, struct list *instrs, bool decrem
{
struct hlsl_ir_expr *copy;
- if (!(copy = hlsl_new_copy(lhs)))
+ if (!(copy = hlsl_new_copy(ctx, lhs)))
return false;
list_add_tail(instrs, ©->node.entry);
@@ -1357,7 +1357,7 @@ static void struct_var_initializer(struct hlsl_ctx *ctx, struct list *list, stru
break;
list_add_tail(list, &c->node.entry);
- if (!(store = hlsl_new_store(var, &c->node, node, 0, node->loc)))
+ if (!(store = hlsl_new_store(ctx, var, &c->node, node, 0, node->loc)))
break;
list_add_tail(list, &store->node.entry);
}
@@ -1391,7 +1391,7 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
if (basic_type->type == HLSL_CLASS_MATRIX)
assert(basic_type->modifiers & HLSL_MODIFIERS_MAJORITY_MASK);
- if (!(statements_list = make_empty_list()))
+ if (!(statements_list = make_empty_list(ctx)))
{
LIST_FOR_EACH_ENTRY_SAFE(v, v_next, var_list, struct parse_variable_def, entry)
free_parse_variable_def(v);
@@ -1413,7 +1413,7 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
if (type->type != HLSL_CLASS_MATRIX)
check_invalid_matrix_modifiers(ctx, modifiers, v->loc);
- if (!(var = hlsl_new_var(v->name, type, v->loc, &v->semantic, modifiers, v->reg_reservation)))
+ if (!(var = hlsl_new_var(ctx, v->name, type, v->loc, &v->semantic, modifiers, v->reg_reservation)))
{
free_parse_variable_def(v);
continue;
@@ -1538,7 +1538,7 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
continue;
}
- load = hlsl_new_var_load(var, var->loc);
+ load = hlsl_new_var_load(ctx, var, var->loc);
list_add_tail(v->initializer.instrs, &load->node.entry);
add_assignment(ctx, v->initializer.instrs, &load->node, ASSIGN_OP_ASSIGN, v->initializer.args[0]);
vkd3d_free(v->initializer.args);
@@ -1800,7 +1800,7 @@ hlsl_prog:
}
}
- hlsl_add_function(&ctx->functions, $2.name, $2.decl, false);
+ hlsl_add_function(ctx, $2.name, $2.decl, false);
}
| hlsl_prog declaration_statement
{
@@ -1893,7 +1893,7 @@ any_identifier:
fields_list:
%empty
{
- if (!($$ = make_empty_list()))
+ if (!($$ = make_empty_list(ctx)))
YYABORT;
}
| fields_list field
@@ -1996,7 +1996,7 @@ func_prototype:
compound_statement:
'{' '}'
{
- if (!($$ = make_empty_list()))
+ if (!($$ = make_empty_list(ctx)))
YYABORT;
}
| '{' scope_start statement_list '}'
@@ -2048,7 +2048,7 @@ semantic:
register_opt:
':' KW_REGISTER '(' any_identifier ')'
{
- $$ = parse_reg_reservation($4);
+ $$ = parse_reg_reservation(ctx, $4);
vkd3d_free($4);
}
| ':' KW_REGISTER '(' any_identifier ',' any_identifier ')'
@@ -2056,14 +2056,14 @@ register_opt:
FIXME("Ignoring shader target %s in a register reservation.\n", debugstr_a($4));
vkd3d_free($4);
- $$ = parse_reg_reservation($6);
+ $$ = parse_reg_reservation(ctx, $6);
vkd3d_free($6);
}
parameters:
scope_start
{
- if (!($$ = make_empty_list()))
+ if (!($$ = make_empty_list(ctx)))
YYABORT;
}
| scope_start param_list
@@ -2074,12 +2074,11 @@ parameters:
param_list:
parameter
{
- if (!($$ = make_empty_list()))
+ if (!($$ = make_empty_list(ctx)))
YYABORT;
if (!add_func_parameter(ctx, $$, &$1, @1))
{
ERR("Error adding function parameter %s.\n", $1.name);
- ctx->failed = true;
YYABORT;
}
}
@@ -2244,7 +2243,7 @@ declaration_statement:
| struct_declaration
| typedef
{
- if (!($$ = make_empty_list()))
+ if (!($$ = make_empty_list(ctx)))
YYABORT;
}
@@ -2272,7 +2271,7 @@ typedef:
type_specs:
type_spec
{
- if (!($$ = make_empty_list()))
+ if (!($$ = make_empty_list(ctx)))
YYABORT;
list_add_head($$, &$1->entry);
}
@@ -2285,7 +2284,7 @@ type_specs:
type_spec:
any_identifier arrays
{
- $$ = vkd3d_calloc(1, sizeof(*$$));
+ $$ = hlsl_alloc(ctx, sizeof(*$$));
$$->loc = @1;
$$->name = $1;
$$->arrays = $2;
@@ -2312,7 +2311,7 @@ variables_def_optional:
variables_def:
variable_def
{
- if (!($$ = make_empty_list()))
+ if (!($$ = make_empty_list(ctx)))
YYABORT;
list_add_head($$, &$1->entry);
}
@@ -2325,7 +2324,7 @@ variables_def:
variable_def:
any_identifier arrays colon_attribute
{
- $$ = vkd3d_calloc(1, sizeof(*$$));
+ $$ = hlsl_alloc(ctx, sizeof(*$$));
$$->loc = @1;
$$->name = $1;
$$->arrays = $2;
@@ -2334,7 +2333,7 @@ variable_def:
}
| any_identifier arrays colon_attribute '=' complex_initializer
{
- $$ = vkd3d_calloc(1, sizeof(*$$));
+ $$ = hlsl_alloc(ctx, sizeof(*$$));
$$->loc = @1;
$$->name = $1;
$$->arrays = $2;
@@ -2437,7 +2436,7 @@ complex_initializer:
initializer_expr
{
$$.args_count = 1;
- if (!($$.args = vkd3d_malloc(sizeof(*$$.args))))
+ if (!($$.args = hlsl_alloc(ctx, sizeof(*$$.args))))
YYABORT;
$$.args[0] = node_from_list($1);
$$.instrs = $1;
@@ -2458,7 +2457,7 @@ initializer_expr_list:
initializer_expr
{
$$.args_count = 1;
- if (!($$.args = vkd3d_malloc(sizeof(*$$.args))))
+ if (!($$.args = hlsl_alloc(ctx, sizeof(*$$.args))))
YYABORT;
$$.args[0] = node_from_list($1);
$$.instrs = $1;
@@ -2509,7 +2508,7 @@ jump_statement:
}
| KW_RETURN ';'
{
- if (!($$ = make_empty_list()))
+ if (!($$ = make_empty_list(ctx)))
YYABORT;
if (!add_return(ctx, $$, NULL, @1))
YYABORT;
@@ -2521,7 +2520,7 @@ selection_statement:
struct hlsl_ir_node *condition = node_from_list($3);
struct hlsl_ir_if *instr;
- if (!(instr = hlsl_new_if(condition, @1)))
+ if (!(instr = hlsl_new_if(ctx, condition, @1)))
YYABORT;
list_move_tail(&instr->then_instrs, $5.then_instrs);
list_move_tail(&instr->else_instrs, $5.else_instrs);
@@ -2555,27 +2554,27 @@ if_body:
loop_statement:
KW_WHILE '(' expr ')' statement
{
- $$ = create_loop(LOOP_WHILE, NULL, $3, NULL, $5, @1);
+ $$ = create_loop(ctx, LOOP_WHILE, NULL, $3, NULL, $5, @1);
}
| KW_DO statement KW_WHILE '(' expr ')' ';'
{
- $$ = create_loop(LOOP_DO_WHILE, NULL, $5, NULL, $2, @1);
+ $$ = create_loop(ctx, LOOP_DO_WHILE, NULL, $5, NULL, $2, @1);
}
| KW_FOR '(' scope_start expr_statement expr_statement expr ')' statement
{
- $$ = create_loop(LOOP_FOR, $4, $5, $6, $8, @1);
+ $$ = create_loop(ctx, LOOP_FOR, $4, $5, $6, $8, @1);
hlsl_pop_scope(ctx);
}
| KW_FOR '(' scope_start declaration expr_statement expr ')' statement
{
- $$ = create_loop(LOOP_FOR, $4, $5, $6, $8, @1);
+ $$ = create_loop(ctx, LOOP_FOR, $4, $5, $6, $8, @1);
hlsl_pop_scope(ctx);
}
expr_statement:
';'
{
- if (!($$ = make_empty_list()))
+ if (!($$ = make_empty_list(ctx)))
YYABORT;
}
| expr ';'
@@ -2588,33 +2587,33 @@ primary_expr:
{
struct hlsl_ir_constant *c;
- if (!(c = vkd3d_malloc(sizeof(*c))))
+ if (!(c = hlsl_alloc(ctx, sizeof(*c))))
YYABORT;
init_node(&c->node, HLSL_IR_CONSTANT, ctx->builtin_types.scalar[HLSL_TYPE_FLOAT], @1);
c->value.f[0] = $1;
- if (!($$ = make_list(&c->node)))
+ if (!($$ = make_list(ctx, &c->node)))
YYABORT;
}
| C_INTEGER
{
struct hlsl_ir_constant *c;
- if (!(c = vkd3d_malloc(sizeof(*c))))
+ if (!(c = hlsl_alloc(ctx, sizeof(*c))))
YYABORT;
init_node(&c->node, HLSL_IR_CONSTANT, ctx->builtin_types.scalar[HLSL_TYPE_INT], @1);
c->value.i[0] = $1;
- if (!($$ = make_list(&c->node)))
+ if (!($$ = make_list(ctx, &c->node)))
YYABORT;
}
| boolean
{
struct hlsl_ir_constant *c;
- if (!(c = vkd3d_malloc(sizeof(*c))))
+ if (!(c = hlsl_alloc(ctx, sizeof(*c))))
YYABORT;
init_node(&c->node, HLSL_IR_CONSTANT, ctx->builtin_types.scalar[HLSL_TYPE_BOOL], @1);
c->value.b[0] = $1;
- if (!($$ = make_list(&c->node)))
+ if (!($$ = make_list(ctx, &c->node)))
YYABORT;
}
| VAR_IDENTIFIER
@@ -2627,9 +2626,9 @@ primary_expr:
hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Variable \"%s\" is not defined.", $1);
YYABORT;
}
- if ((load = hlsl_new_var_load(var, @1)))
+ if ((load = hlsl_new_var_load(ctx, var, @1)))
{
- if (!($$ = make_list(&load->node)))
+ if (!($$ = make_list(ctx, &load->node)))
YYABORT;
}
else
@@ -2711,7 +2710,7 @@ postfix_expr:
YYABORT;
}
- if (!(cast = hlsl_new_cast(index, ctx->builtin_types.scalar[HLSL_TYPE_UINT], &index->loc)))
+ if (!(cast = hlsl_new_cast(ctx, index, ctx->builtin_types.scalar[HLSL_TYPE_UINT], &index->loc)))
{
hlsl_free_instr_list($1);
YYABORT;
@@ -2793,14 +2792,14 @@ postfix_expr:
ctx->builtin_types.vector[$2->base_type][width - 1], &arg->loc)))
continue;
- if (!(store = hlsl_new_store(var, NULL, arg,
+ if (!(store = hlsl_new_store(ctx, var, NULL, arg,
((1 << width) - 1) << writemask_offset, arg->loc)))
YYABORT;
writemask_offset += width;
list_add_tail($4.instrs, &store->node.entry);
}
vkd3d_free($4.args);
- if (!(load = hlsl_new_var_load(var, @2)))
+ if (!(load = hlsl_new_var_load(ctx, var, @2)))
YYABORT;
$$ = append_unop($4.instrs, &load->node);
}
@@ -2833,7 +2832,7 @@ unary_expr:
if ($1 == UNARY_OP_PLUS)
$$ = $2;
else
- $$ = append_unop($2, hlsl_new_unary_expr(ops[$1], node_from_list($2), @1));
+ $$ = append_unop($2, hlsl_new_unary_expr(ctx, ops[$1], node_from_list($2), @1));
}
/* var_modifiers is necessary to avoid shift/reduce conflicts. */
@@ -2868,7 +2867,7 @@ unary_expr:
YYABORT;
}
- $$ = append_unop($6, &hlsl_new_cast(node_from_list($6), dst_type, &@3)->node);
+ $$ = append_unop($6, &hlsl_new_cast(ctx, node_from_list($6), dst_type, &@3)->node);
}
unary_op:
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c
index c2cedd2a..1705529e 100644
--- a/libs/vkd3d-shader/hlsl_codegen.c
+++ b/libs/vkd3d-shader/hlsl_codegen.c
@@ -35,11 +35,8 @@ static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct list *instrs, stru
/* Use the synthetic name for the temp, rather than the uniform, so that we
* can write the uniform name into the shader reflection data. */
- if (!(uniform = hlsl_new_var(temp->name, temp->data_type, temp->loc, NULL, 0, temp->reg_reservation)))
- {
- ctx->failed = true;
+ if (!(uniform = hlsl_new_var(ctx, temp->name, temp->data_type, temp->loc, NULL, 0, temp->reg_reservation)))
return;
- }
list_add_before(&temp->scope_entry, &uniform->scope_entry);
list_add_tail(&ctx->extern_vars, &uniform->extern_entry);
uniform->is_uniform = 1;
@@ -51,21 +48,15 @@ static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct list *instrs, stru
return;
}
vkd3d_string_buffer_printf(name, "<temp-%s>", temp->name);
- temp->name = vkd3d_strdup(name->buffer);
+ temp->name = hlsl_strdup(ctx, name->buffer);
vkd3d_string_buffer_release(&ctx->string_buffers, name);
- if (!(load = hlsl_new_var_load(uniform, temp->loc)))
- {
- ctx->failed = true;
+ if (!(load = hlsl_new_var_load(ctx, uniform, temp->loc)))
return;
- }
list_add_head(instrs, &load->node.entry);
- if (!(store = hlsl_new_simple_store(temp, &load->node)))
- {
- ctx->failed = true;
+ if (!(store = hlsl_new_simple_store(ctx, temp, &load->node)))
return;
- }
list_add_after(&load->node.entry, &store->node.entry);
}
@@ -85,18 +76,16 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct
return;
}
vkd3d_string_buffer_printf(name, "<input-%s%u>", semantic->name, semantic->index);
- if (!(new_semantic.name = vkd3d_strdup(semantic->name)))
+ if (!(new_semantic.name = hlsl_strdup(ctx, semantic->name)))
{
vkd3d_string_buffer_release(&ctx->string_buffers, name);
- ctx->failed = true;
return;
}
new_semantic.index = semantic->index;
- if (!(input = hlsl_new_var(vkd3d_strdup(name->buffer), type, var->loc, &new_semantic, 0, NULL)))
+ if (!(input = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer), type, var->loc, &new_semantic, 0, NULL)))
{
vkd3d_string_buffer_release(&ctx->string_buffers, name);
vkd3d_free((void *)new_semantic.name);
- ctx->failed = true;
return;
}
vkd3d_string_buffer_release(&ctx->string_buffers, name);
@@ -105,25 +94,16 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct
list_add_before(&var->scope_entry, &input->scope_entry);
list_add_tail(&ctx->extern_vars, &input->extern_entry);
- if (!(load = hlsl_new_var_load(input, var->loc)))
- {
- ctx->failed = true;
+ if (!(load = hlsl_new_var_load(ctx, input, var->loc)))
return;
- }
list_add_head(instrs, &load->node.entry);
if (!(offset = hlsl_new_uint_constant(ctx, field_offset * 4, var->loc)))
- {
- ctx->failed = true;
return;
- }
list_add_after(&load->node.entry, &offset->node.entry);
- if (!(store = hlsl_new_store(var, &offset->node, &load->node, 0, var->loc)))
- {
- ctx->failed = true;
+ if (!(store = hlsl_new_store(ctx, var, &offset->node, &load->node, 0, var->loc)))
return;
- }
list_add_after(&offset->node.entry, &store->node.entry);
}
@@ -170,18 +150,16 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct
return;
}
vkd3d_string_buffer_printf(name, "<output-%s%u>", semantic->name, semantic->index);
- if (!(new_semantic.name = vkd3d_strdup(semantic->name)))
+ if (!(new_semantic.name = hlsl_strdup(ctx, semantic->name)))
{
vkd3d_string_buffer_release(&ctx->string_buffers, name);
- ctx->failed = true;
return;
}
new_semantic.index = semantic->index;
- if (!(output = hlsl_new_var(vkd3d_strdup(name->buffer), type, var->loc, &new_semantic, 0, NULL)))
+ if (!(output = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer), type, var->loc, &new_semantic, 0, NULL)))
{
vkd3d_free((void *)new_semantic.name);
vkd3d_string_buffer_release(&ctx->string_buffers, name);
- ctx->failed = true;
return;
}
vkd3d_string_buffer_release(&ctx->string_buffers, name);
@@ -191,24 +169,15 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct
list_add_tail(&ctx->extern_vars, &output->extern_entry);
if (!(offset = hlsl_new_uint_constant(ctx, field_offset * 4, var->loc)))
- {
- ctx->failed = true;
return;
- }
list_add_tail(instrs, &offset->node.entry);
- if (!(load = hlsl_new_load(var, &offset->node, type, var->loc)))
- {
- ctx->failed = true;
+ if (!(load = hlsl_new_load(ctx, var, &offset->node, type, var->loc)))
return;
- }
list_add_after(&offset->node.entry, &load->node.entry);
- if (!(store = hlsl_new_store(output, NULL, &load->node, 0, var->loc)))
- {
- ctx->failed = true;
+ if (!(store = hlsl_new_store(ctx, output, NULL, &load->node, 0, var->loc)))
return;
- }
list_add_after(&load->node.entry, &store->node.entry);
}
@@ -331,47 +300,32 @@ static bool split_struct_copies(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr
struct hlsl_ir_constant *c;
if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset * 4, instr->loc)))
- {
- ctx->failed = true;
return false;
- }
list_add_before(&instr->entry, &c->node.entry);
offset = &c->node;
if (rhs_load->src.offset.node)
{
- if (!(add = hlsl_new_binary_expr(HLSL_IR_BINOP_ADD, rhs_load->src.offset.node, &c->node)))
- {
- ctx->failed = true;
+ if (!(add = hlsl_new_binary_expr(ctx, HLSL_IR_BINOP_ADD, rhs_load->src.offset.node, &c->node)))
return false;
- }
list_add_before(&instr->entry, &add->entry);
offset = add;
}
- if (!(field_load = hlsl_new_load(rhs_load->src.var, offset, field->type, instr->loc)))
- {
- ctx->failed = true;
+ if (!(field_load = hlsl_new_load(ctx, rhs_load->src.var, offset, field->type, instr->loc)))
return false;
- }
list_add_before(&instr->entry, &field_load->node.entry);
offset = &c->node;
if (store->lhs.offset.node)
{
- if (!(add = hlsl_new_binary_expr(HLSL_IR_BINOP_ADD, store->lhs.offset.node, &c->node)))
- {
- ctx->failed = true;
+ if (!(add = hlsl_new_binary_expr(ctx, HLSL_IR_BINOP_ADD, store->lhs.offset.node, &c->node)))
return false;
- }
list_add_before(&instr->entry, &add->entry);
offset = add;
}
- if (!(field_store = hlsl_new_store(store->lhs.var, offset, &field_load->node, 0, instr->loc)))
- {
- ctx->failed = true;
+ if (!(field_store = hlsl_new_store(ctx, store->lhs.var, offset, &field_load->node, 0, instr->loc)))
return false;
- }
list_add_before(&instr->entry, &field_store->node.entry);
}
@@ -402,11 +356,8 @@ static bool fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, voi
if (expr->operands[1].node)
arg2 = hlsl_ir_constant(expr->operands[1].node);
- if (!(res = vkd3d_calloc(1, sizeof(*res))))
- {
- ctx->failed = true;
+ if (!(res = hlsl_alloc(ctx, sizeof(*res))))
return false;
- }
init_node(&res->node, HLSL_IR_CONSTANT, instr->data_type, instr->loc);
switch (instr->data_type->base_type)
@@ -657,11 +608,11 @@ static unsigned int get_available_writemask(struct liveness *liveness,
return 0;
}
-static bool resize_liveness(struct liveness *liveness, size_t new_count)
+static bool resize_liveness(struct hlsl_ctx *ctx, struct liveness *liveness, size_t new_count)
{
size_t old_capacity = liveness->size;
- if (!vkd3d_array_reserve((void **)&liveness->regs, &liveness->size, new_count, sizeof(*liveness->regs)))
+ if (!hlsl_array_reserve(ctx, (void **)&liveness->regs, &liveness->size, new_count, sizeof(*liveness->regs)))
return false;
if (liveness->size > old_capacity)
@@ -669,7 +620,7 @@ static bool resize_liveness(struct liveness *liveness, size_t new_count)
return true;
}
-static struct hlsl_reg allocate_register(struct liveness *liveness,
+static struct hlsl_reg allocate_register(struct hlsl_ctx *ctx, struct liveness *liveness,
unsigned int first_write, unsigned int last_read, unsigned int component_count)
{
unsigned int component_idx, writemask, i;
@@ -682,7 +633,7 @@ static struct hlsl_reg allocate_register(struct liveness *liveness,
}
if (component_idx == liveness->size)
{
- if (!resize_liveness(liveness, component_idx + 4))
+ if (!resize_liveness(ctx, liveness, component_idx + 4))
return ret;
writemask = (1u << component_count) - 1;
}
@@ -710,7 +661,7 @@ static bool is_range_available(struct liveness *liveness, unsigned int first_wri
return true;
}
-static struct hlsl_reg allocate_range(struct liveness *liveness,
+static struct hlsl_reg allocate_range(struct hlsl_ctx *ctx, struct liveness *liveness,
unsigned int first_write, unsigned int last_read, unsigned int reg_count)
{
const unsigned int component_count = reg_count * 4;
@@ -723,7 +674,7 @@ static struct hlsl_reg allocate_range(struct liveness *liveness,
min(component_count, liveness->size - component_idx)))
break;
}
- if (!resize_liveness(liveness, component_idx + component_count))
+ if (!resize_liveness(ctx, liveness, component_idx + component_count))
return ret;
for (i = 0; i < component_count; ++i)
@@ -741,7 +692,7 @@ static const char *debug_register(char class, struct hlsl_reg reg, const struct
return vkd3d_dbg_sprintf("%c%u%s", class, reg.id, debug_hlsl_writemask(reg.writemask));
}
-static void allocate_variable_temp_register(struct hlsl_ir_var *var, struct liveness *liveness)
+static void allocate_variable_temp_register(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, struct liveness *liveness)
{
if (var->is_input_semantic || var->is_output_semantic || var->is_uniform)
return;
@@ -749,17 +700,17 @@ static void allocate_variable_temp_register(struct hlsl_ir_var *var, struct live
if (!var->reg.allocated && var->last_read)
{
if (var->data_type->reg_size > 1)
- var->reg = allocate_range(liveness, var->first_write,
+ var->reg = allocate_range(ctx, liveness, var->first_write,
var->last_read, var->data_type->reg_size);
else
- var->reg = allocate_register(liveness, var->first_write,
+ var->reg = allocate_register(ctx, liveness, var->first_write,
var->last_read, var->data_type->dimx);
TRACE("Allocated %s to %s (liveness %u-%u).\n", var->name,
debug_register('r', var->reg, var->data_type), var->first_write, var->last_read);
}
}
-static void allocate_temp_registers_recurse(struct list *instrs, struct liveness *liveness)
+static void allocate_temp_registers_recurse(struct hlsl_ctx *ctx, struct list *instrs, struct liveness *liveness)
{
struct hlsl_ir_node *instr;
@@ -768,10 +719,10 @@ static void allocate_temp_registers_recurse(struct list *instrs, struct liveness
if (!instr->reg.allocated && instr->last_read)
{
if (instr->data_type->reg_size > 1)
- instr->reg = allocate_range(liveness, instr->index,
+ instr->reg = allocate_range(ctx, liveness, instr->index,
instr->last_read, instr->data_type->reg_size);
else
- instr->reg = allocate_register(liveness, instr->index,
+ instr->reg = allocate_register(ctx, liveness, instr->index,
instr->last_read, instr->data_type->dimx);
TRACE("Allocated anonymous expression @%u to %s (liveness %u-%u).\n", instr->index,
debug_register('r', instr->reg, instr->data_type), instr->index, instr->last_read);
@@ -782,8 +733,8 @@ static void allocate_temp_registers_recurse(struct list *instrs, struct liveness
case HLSL_IR_IF:
{
struct hlsl_ir_if *iff = hlsl_ir_if(instr);
- allocate_temp_registers_recurse(&iff->then_instrs, liveness);
- allocate_temp_registers_recurse(&iff->else_instrs, liveness);
+ allocate_temp_registers_recurse(ctx, &iff->then_instrs, liveness);
+ allocate_temp_registers_recurse(ctx, &iff->else_instrs, liveness);
break;
}
@@ -792,21 +743,21 @@ static void allocate_temp_registers_recurse(struct list *instrs, struct liveness
struct hlsl_ir_load *load = hlsl_ir_load(instr);
/* We need to at least allocate a variable for undefs.
* FIXME: We should probably find a way to remove them instead. */
- allocate_variable_temp_register(load->src.var, liveness);
+ allocate_variable_temp_register(ctx, load->src.var, liveness);
break;
}
case HLSL_IR_LOOP:
{
struct hlsl_ir_loop *loop = hlsl_ir_loop(instr);
- allocate_temp_registers_recurse(&loop->body, liveness);
+ allocate_temp_registers_recurse(ctx, &loop->body, liveness);
break;
}
case HLSL_IR_STORE:
{
struct hlsl_ir_store *store = hlsl_ir_store(instr);
- allocate_variable_temp_register(store->lhs.var, liveness);
+ allocate_variable_temp_register(ctx, store->lhs.var, liveness);
break;
}
@@ -833,17 +784,14 @@ static void allocate_const_registers_recurse(struct hlsl_ctx *ctx, struct list *
unsigned int x, y, i, writemask;
if (reg_size > 1)
- constant->reg = allocate_range(liveness, 1, UINT_MAX, reg_size);
+ constant->reg = allocate_range(ctx, liveness, 1, UINT_MAX, reg_size);
else
- constant->reg = allocate_register(liveness, 1, UINT_MAX, type->dimx);
+ constant->reg = allocate_register(ctx, liveness, 1, UINT_MAX, type->dimx);
TRACE("Allocated constant @%u to %s.\n", instr->index, debug_register('c', constant->reg, type));
- if (!vkd3d_array_reserve((void **)&defs->values, &defs->size,
+ if (!hlsl_array_reserve(ctx, (void **)&defs->values, &defs->size,
constant->reg.id + reg_size, sizeof(*defs->values)))
- {
- ctx->failed = true;
return;
- }
defs->count = max(defs->count, constant->reg.id + reg_size);
assert(type->type <= HLSL_CLASS_LAST_NUMERIC);
@@ -927,10 +875,10 @@ static void allocate_const_registers(struct hlsl_ctx *ctx, struct hlsl_ir_functi
if (var->is_uniform && var->last_read)
{
if (var->data_type->reg_size > 1)
- var->reg = allocate_range(&liveness, 1, UINT_MAX, var->data_type->reg_size);
+ var->reg = allocate_range(ctx, &liveness, 1, UINT_MAX, var->data_type->reg_size);
else
{
- var->reg = allocate_register(&liveness, 1, UINT_MAX, 4);
+ var->reg = allocate_register(ctx, &liveness, 1, UINT_MAX, 4);
var->reg.writemask = (1u << var->data_type->dimx) - 1;
}
TRACE("Allocated %s to %s.\n", var->name, debug_register('c', var->reg, var->data_type));
@@ -942,10 +890,10 @@ static void allocate_const_registers(struct hlsl_ctx *ctx, struct hlsl_ir_functi
* index to all (simultaneously live) variables or intermediate values. Agnostic
* as to how many registers are actually available for the current backend, and
* does not handle constants. */
-static void allocate_temp_registers(struct hlsl_ir_function_decl *entry_func)
+static void allocate_temp_registers(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func)
{
struct liveness liveness = {0};
- allocate_temp_registers_recurse(entry_func->body, &liveness);
+ allocate_temp_registers_recurse(ctx, entry_func->body, &liveness);
}
static bool sm1_register_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semantic *semantic, bool output,
@@ -1216,6 +1164,7 @@ static struct hlsl_reg hlsl_reg_from_deref(const struct hlsl_deref *deref, const
struct bytecode_buffer
{
+ struct hlsl_ctx *ctx;
uint32_t *data;
size_t count, size;
int status;
@@ -1229,7 +1178,8 @@ static unsigned int put_dword(struct bytecode_buffer *buffer, uint32_t value)
if (buffer->status)
return index;
- if (!vkd3d_array_reserve((void **)&buffer->data, &buffer->size, buffer->count + 1, sizeof(*buffer->data)))
+ if (!hlsl_array_reserve(buffer->ctx, (void **)&buffer->data, &buffer->size,
+ buffer->count + 1, sizeof(*buffer->data)))
{
buffer->status = VKD3D_ERROR_OUT_OF_MEMORY;
return index;
@@ -1270,7 +1220,8 @@ static unsigned int put_string(struct bytecode_buffer *buffer, const char *str)
if (buffer->status)
return index;
- if (!vkd3d_array_reserve((void **)&buffer->data, &buffer->size, buffer->count + token_count, sizeof(*buffer->data)))
+ if (!hlsl_array_reserve(buffer->ctx, (void **)&buffer->data, &buffer->size,
+ buffer->count + token_count, sizeof(*buffer->data)))
{
buffer->status = E_OUTOFMEMORY;
return index;
@@ -1478,7 +1429,7 @@ static void write_sm1_uniforms(struct hlsl_ctx *ctx, struct bytecode_buffer *buf
}
vkd3d_string_buffer_printf(name, "$%s", var->name);
vkd3d_free((char *)var->name);
- var->name = vkd3d_strdup(name->buffer);
+ var->name = hlsl_strdup(ctx, name->buffer);
vkd3d_string_buffer_release(&ctx->string_buffers, name);
}
}
@@ -1936,7 +1887,7 @@ static void write_sm1_instructions(struct hlsl_ctx *ctx, struct bytecode_buffer
static int write_sm1_shader(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func,
struct vkd3d_shader_code *out)
{
- struct bytecode_buffer buffer = {0};
+ struct bytecode_buffer buffer = {.ctx = ctx};
int ret;
put_dword(&buffer, sm1_version(ctx->profile->type, ctx->profile->major_version, ctx->profile->minor_version));
@@ -2018,7 +1969,7 @@ int hlsl_emit_dxbc(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_fun
if (TRACE_ON())
rb_for_each_entry(&ctx->functions, dump_function, NULL);
- allocate_temp_registers(entry_func);
+ allocate_temp_registers(ctx, entry_func);
if (ctx->profile->major_version < 4)
allocate_const_registers(ctx, entry_func);
allocate_semantic_registers(ctx);
--
2.31.1
4
15
[PATCH v7 1/4] winevulkan: Support use of extensions which mustn't be exposed.
by Derek Lesho 10 Jun '21
by Derek Lesho 10 Jun '21
10 Jun '21
Signed-off-by: Derek Lesho <dlesho(a)codeweavers.com>
---
v7: Fixed typo whereupon the presence the of the is_required method was checked, rather than the return value.
---
dlls/winevulkan/make_vulkan | 35 ++++++++++++++++++++++++-----------
1 file changed, 24 insertions(+), 11 deletions(-)
diff --git a/dlls/winevulkan/make_vulkan b/dlls/winevulkan/make_vulkan
index 7f76d328fc8..34dd9fc432f 100755
--- a/dlls/winevulkan/make_vulkan
+++ b/dlls/winevulkan/make_vulkan
@@ -120,6 +120,11 @@ UNSUPPORTED_EXTENSIONS = [
"VK_NV_external_memory_win32",
]
+# Either internal extensions which aren't present on the win32 platform which
+# winevulkan may nonetheless use, or extensions we want to generate headers for
+# but not expose to applications (useful for test commits)
+UNEXPOSED_EXTENSIONS = {}
+
# The Vulkan loader provides entry-points for core functionality and important
# extensions. Based on vulkan-1.def this amounts to WSI extensions on 1.0.51.
CORE_EXTENSIONS = [
@@ -521,8 +526,8 @@ class VkEnumValue(object):
class VkFunction(object):
- def __init__(self, _type=None, name=None, params=[], extensions=[], alias=None):
- self.extensions = []
+ def __init__(self, _type=None, name=None, params=[], alias=None):
+ self.extensions = set()
self.name = name
self.type = _type
self.params = params
@@ -665,6 +670,10 @@ class VkFunction(object):
def needs_private_thunk(self):
return self.thunk_type == ThunkType.PRIVATE
+ def needs_exposing(self):
+ # The function needs exposed if at-least one extension isn't both UNSUPPORTED and UNEXPOSED
+ return self.is_required() and (not self.extensions or not self.extensions.issubset(UNEXPOSED_EXTENSIONS))
+
def pfn(self, prefix="p", call_conv=None, conv=False):
""" Create function pointer. """
@@ -2653,7 +2662,7 @@ class VkGenerator(object):
# Create thunks for instance and device functions.
# Global functions don't go through the thunks.
for vk_func in self.registry.funcs.values():
- if not vk_func.is_required():
+ if not vk_func.needs_exposing():
continue
if vk_func.is_global_func():
@@ -2676,6 +2685,8 @@ class VkGenerator(object):
for ext in self.registry.extensions:
if ext["type"] != "device":
continue
+ if ext["name"] in UNEXPOSED_EXTENSIONS:
+ continue
f.write(" \"{0}\",\n".format(ext["name"]))
f.write("};\n\n")
@@ -2685,6 +2696,8 @@ class VkGenerator(object):
for ext in self.registry.extensions:
if ext["type"] != "instance":
continue
+ if ext["name"] in UNEXPOSED_EXTENSIONS:
+ continue
f.write(" \"{0}\",\n".format(ext["name"]))
f.write("};\n\n")
@@ -2744,7 +2757,7 @@ class VkGenerator(object):
f.write("const struct unix_funcs loader_funcs =\n")
f.write("{\n")
for vk_func in self.registry.funcs.values():
- if not vk_func.is_required():
+ if not vk_func.needs_exposing():
continue
if vk_func.loader_thunk_type == ThunkType.NONE:
continue
@@ -2763,7 +2776,7 @@ class VkGenerator(object):
# Generate prototypes for device and instance functions requiring a custom implementation.
f.write("/* Functions for which we have custom implementations outside of the thunks. */\n")
for vk_func in self.registry.funcs.values():
- if not vk_func.is_required():
+ if not vk_func.needs_exposing():
continue
if vk_func.needs_thunk() and not vk_func.needs_private_thunk():
continue
@@ -2872,7 +2885,7 @@ class VkGenerator(object):
f.write("WINE_DEFAULT_DEBUG_CHANNEL(vulkan);\n\n")
for vk_func in self.registry.funcs.values():
- if not vk_func.is_required():
+ if not vk_func.needs_exposing():
continue
if vk_func.loader_thunk_type != ThunkType.PUBLIC:
continue
@@ -2881,7 +2894,7 @@ class VkGenerator(object):
f.write("static const struct vulkan_func vk_device_dispatch_table[] =\n{\n")
for vk_func in self.registry.device_funcs:
- if not vk_func.is_required():
+ if not vk_func.needs_exposing():
continue
f.write(" {{\"{0}\", &{0}}},\n".format(vk_func.name))
@@ -2889,7 +2902,7 @@ class VkGenerator(object):
f.write("static const struct vulkan_func vk_phys_dev_dispatch_table[] =\n{\n")
for vk_func in self.registry.phys_dev_funcs:
- if not vk_func.is_required():
+ if not vk_func.needs_exposing():
continue
f.write(" {{\"{0}\", &{0}}},\n".format(vk_func.name))
@@ -2897,7 +2910,7 @@ class VkGenerator(object):
f.write("static const struct vulkan_func vk_instance_dispatch_table[] =\n{\n")
for vk_func in self.registry.instance_funcs:
- if not vk_func.is_required():
+ if not vk_func.needs_exposing():
continue
f.write(" {{\"{0}\", &{0}}},\n".format(vk_func.name))
@@ -2954,7 +2967,7 @@ class VkGenerator(object):
f.write("struct unix_funcs\n")
f.write("{\n")
for vk_func in self.registry.funcs.values():
- if not vk_func.is_required():
+ if not vk_func.needs_exposing():
continue
if vk_func.loader_thunk_type == ThunkType.NONE:
continue
@@ -3447,7 +3460,7 @@ class VkRegistry(object):
# the XML file to handle this, but because of the manner in which we parse the XML
# file we pre-populate from <commands> before we check if a command is enabled.
if cmd_name in self.funcs:
- self.funcs[cmd_name].extensions.append(ext_name)
+ self.funcs[cmd_name].extensions.add(ext_name)
# Some extensions are not ready or have numbers reserved as a place holder.
if ext.attrib["supported"] == "disabled":
--
2.31.1
4
18
Signed-off-by: Jactry Zeng <jzeng(a)codeweavers.com>
---
Superseded patch 206432 to 206436.
---
dlls/riched20/tests/richole.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c
index c2457ae5146..a76f9fdaf2e 100644
--- a/dlls/riched20/tests/richole.c
+++ b/dlls/riched20/tests/richole.c
@@ -3252,7 +3252,7 @@ static void test_InsertObject(void)
REOBJECT reo1, reo2, reo3, received_reo;
HRESULT hr;
HWND hwnd;
- const WCHAR *expected_string;
+ const WCHAR *expected_string, *string;
const CHAR *expected_stringA;
ITextSelection *selection;
IDataObject *dataobject;
@@ -3465,8 +3465,10 @@ static void test_InsertObject(void)
formatetc.lindex = -1;
hr = IDataObject_GetData(dataobject, &formatetc, &stgmedium);
ok(hr == S_OK, "Got hr %#x.\n", hr);
- todo_wine ok(lstrlenW(stgmedium.hGlobal) == lstrlenW(expected_string), "Got wrong length: %d.\n", result);
- todo_wine ok(!lstrcmpW(stgmedium.hGlobal, expected_string), "Got wrong content: %s.\n", debugstr_w(stgmedium.hGlobal));
+ string = GlobalLock(stgmedium.hGlobal);
+ ok(lstrlenW(string) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(string));
+ todo_wine ok(!lstrcmpW(string, expected_string), "Got wrong content: %s.\n", debugstr_w(string));
+ GlobalUnlock(stgmedium.hGlobal);
expected_string = L"abc\xfffc""d\xfffc""efg";
gettextex.cb = sizeof(buffer);
--
2.30.2
2
11