Skip to content

Commit d63225c

Browse files
committed
Clean up unused code
Remove redundant state and helper abstractions. Remove device and window creation logic as it is not used anymore. Remove test stats tracking, use the harness instead. Signed-off-by: Ahmed Hesham <ahmed.hesham@arm.com>
1 parent 854c3d5 commit d63225c

7 files changed

Lines changed: 55 additions & 314 deletions

File tree

test_conformance/d3d10/buffer.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,9 @@ void SubTestBuffer(
5858
cl_mem mem = NULL;
5959
cl_int result = CL_SUCCESS;
6060

61-
HarnessD3D10_TestBegin("Buffer: Size=%d, BindFlags=%s, Usage=%s, CPUAccess=%s",
62-
props->ByteWidth,
63-
props->name_BindFlags,
64-
props->name_Usage,
65-
props->name_CPUAccess);
61+
log_info("Buffer: Size=%d, BindFlags=%s, Usage=%s, CPUAccess=%s",
62+
props->ByteWidth, props->name_BindFlags, props->name_Usage,
63+
props->name_CPUAccess);
6664

6765
// create the D3D10 resource
6866
{
@@ -288,8 +286,6 @@ void SubTestBuffer(
288286
{
289287
clReleaseMemObject(mem);
290288
}
291-
292-
HarnessD3D10_TestEnd();
293289
}
294290

295291

test_conformance/d3d10/harness.cpp

Lines changed: 1 addition & 195 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// Copyright (c) 2017 The Khronos Group Inc.
3-
//
3+
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
66
// You may obtain a copy of the License at
@@ -13,11 +13,7 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515
//
16-
#define INITGUID
1716
#include "harness.h"
18-
#include <vector>
19-
20-
#include <tchar.h>
2117

2218
/*
2319
* OpenCL state
@@ -45,126 +41,6 @@ HarnessD3D10_Initialize(cl_platform_id platform)
4541
INITPFN(clEnqueueReleaseD3D10ObjectsKHR);
4642
}
4743

48-
/*
49-
* Window management
50-
*/
51-
52-
static IDXGISwapChain* HarnessD3D10_pSwapChain = NULL;
53-
static ID3D10Device* HarnessD3D10_pDevice = NULL;
54-
static HWND HarnessD3D10_hWnd = NULL;
55-
56-
static LRESULT WINAPI HarnessD3D10_Proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
57-
{
58-
switch(msg)
59-
{
60-
case WM_KEYDOWN:
61-
return 0;
62-
break;
63-
case WM_DESTROY:
64-
HarnessD3D10_hWnd = NULL;
65-
PostQuitMessage(0);
66-
return 0;
67-
case WM_PAINT:
68-
ValidateRect(hWnd, NULL);
69-
return 0;
70-
}
71-
return DefWindowProc(hWnd, msg, wParam, lParam);
72-
}
73-
74-
static void HarnessD3D10_InteractiveLoop()
75-
{
76-
MSG msg;
77-
while(PeekMessage(&msg,HarnessD3D10_hWnd,0,0,PM_REMOVE))
78-
{
79-
TranslateMessage(&msg);
80-
DispatchMessage(&msg);
81-
}
82-
}
83-
84-
cl_int HarnessD3D10_CreateDevice(IDXGIAdapter* pAdapter, ID3D10Device **ppDevice)
85-
{
86-
HRESULT hr = S_OK;
87-
unsigned int cuStatus = 1;
88-
89-
*ppDevice = NULL;
90-
91-
// create window
92-
static WNDCLASSEX wc =
93-
{
94-
sizeof(WNDCLASSEX),
95-
CS_CLASSDC,
96-
HarnessD3D10_Proc,
97-
0L,
98-
0L,
99-
GetModuleHandle(NULL),
100-
NULL,
101-
NULL,
102-
NULL,
103-
NULL,
104-
_T( "cl_khr_d3d10_sharing_conformance" ),
105-
NULL
106-
};
107-
RegisterClassEx(&wc);
108-
HarnessD3D10_hWnd = CreateWindow(
109-
_T( "cl_khr_d3d10_sharing_conformance" ),
110-
_T( "cl_khr_d3d10_sharing_conformance" ),
111-
WS_OVERLAPPEDWINDOW,
112-
0, 0, 256, 256,
113-
NULL,
114-
NULL,
115-
wc.hInstance,
116-
NULL);
117-
NonTestRequire(0 != HarnessD3D10_hWnd, "Failed to create window");
118-
119-
ShowWindow(HarnessD3D10_hWnd,SW_SHOWDEFAULT);
120-
UpdateWindow(HarnessD3D10_hWnd);
121-
122-
RECT rc;
123-
GetClientRect(HarnessD3D10_hWnd, &rc);
124-
UINT width = rc.right - rc.left;
125-
UINT height = rc.bottom - rc.top;
126-
127-
// Create device and swapchain
128-
DXGI_SWAP_CHAIN_DESC sd;
129-
ZeroMemory(&sd, sizeof(sd));
130-
sd.BufferCount = 1;
131-
sd.BufferDesc.Width = width;
132-
sd.BufferDesc.Height = height;
133-
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
134-
sd.BufferDesc.RefreshRate.Numerator = 60;
135-
sd.BufferDesc.RefreshRate.Denominator = 1;
136-
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
137-
sd.OutputWindow = HarnessD3D10_hWnd;
138-
sd.SampleDesc.Count = 1;
139-
sd.SampleDesc.Quality = 0;
140-
sd.Windowed = TRUE;
141-
hr = D3D10CreateDeviceAndSwapChain(
142-
pAdapter,
143-
D3D10_DRIVER_TYPE_HARDWARE,
144-
NULL,
145-
0,
146-
D3D10_SDK_VERSION,
147-
&sd,
148-
&HarnessD3D10_pSwapChain,
149-
&HarnessD3D10_pDevice);
150-
151-
if (FAILED(hr) ) {
152-
return CL_DEVICE_NOT_FOUND;
153-
}
154-
155-
*ppDevice = HarnessD3D10_pDevice;
156-
return CL_SUCCESS;
157-
}
158-
159-
void HarnessD3D10_DestroyDevice()
160-
{
161-
HarnessD3D10_pSwapChain->Release();
162-
HarnessD3D10_pDevice->Release();
163-
164-
if (HarnessD3D10_hWnd) DestroyWindow(HarnessD3D10_hWnd);
165-
HarnessD3D10_hWnd = 0;
166-
}
167-
16844
/*
16945
*
17046
* texture formats
@@ -215,76 +91,6 @@ TextureFormat formats[] =
21591
};
21692
UINT formatCount = sizeof(formats)/sizeof(formats[0]);
21793

218-
/*
219-
*
220-
* Logging and error reporting
221-
*
222-
*/
223-
224-
static struct
225-
{
226-
cl_int testCount;
227-
cl_int passCount;
228-
229-
cl_int nonTestFailures;
230-
cl_int inTest;
231-
cl_int currentTestPass;
232-
233-
char currentTestName[1024];
234-
} HarnessD3D10_testStats = {0};
235-
236-
void HarnessD3D10_TestBegin(const char* fmt, ...)
237-
{
238-
va_list ap;
239-
240-
va_start(ap, fmt);
241-
vsprintf(HarnessD3D10_testStats.currentTestName, fmt, ap);
242-
va_end(ap);
243-
244-
TestPrint("[%s] ... ", HarnessD3D10_testStats.currentTestName);
245-
246-
HarnessD3D10_testStats.inTest = 1;
247-
HarnessD3D10_testStats.currentTestPass = 1;
248-
}
249-
250-
void HarnessD3D10_TestFail()
251-
{
252-
if (HarnessD3D10_testStats.inTest)
253-
{
254-
HarnessD3D10_testStats.currentTestPass = 0;
255-
}
256-
else
257-
{
258-
++HarnessD3D10_testStats.nonTestFailures;
259-
}
260-
}
261-
262-
void HarnessD3D10_TestEnd()
263-
{
264-
HarnessD3D10_testStats.inTest = 0;
265-
266-
HarnessD3D10_testStats.testCount += 1;
267-
HarnessD3D10_testStats.passCount += HarnessD3D10_testStats.currentTestPass;
268-
269-
TestPrint("%s\n",
270-
HarnessD3D10_testStats.currentTestPass ? "PASSED" : "FAILED");
271-
}
272-
273-
void HarnessD3D10_TestStats()
274-
{
275-
TestPrint("PASSED %d of %d tests.\n", HarnessD3D10_testStats.passCount, HarnessD3D10_testStats.testCount);
276-
if (HarnessD3D10_testStats.testCount > HarnessD3D10_testStats.passCount)
277-
{
278-
TestPrint("***FAILED***\n");
279-
exit(1);
280-
}
281-
else
282-
{
283-
TestPrint("&&&& cl_khr_d3d10_sharing test PASSED\n");
284-
}
285-
exit(0);
286-
}
287-
28894
/*
28995
*
29096
* Helper function

test_conformance/d3d10/harness.h

Lines changed: 13 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,7 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515
//
16-
#ifndef HARNESS_H_
17-
#define HARNESS_H_
18-
19-
#define _CRT_SECURE_NO_WARNINGS
20-
21-
#if defined (__MINGW32__)
22-
#include <rpcsal.h>
23-
typedef unsigned char UINT8;
24-
#define __out
25-
#define __in
26-
#define __inout
27-
#define __out_bcount_opt(size)
28-
#define __in_opt
29-
#define __in_ecount(size)
30-
#define __in_ecount_opt(size)
31-
#define __out_opt
32-
#define __out_ecount(size)
33-
#define __out_ecount_opt(size)
34-
#define __in_bcount_opt(size)
35-
#define __inout_opt
36-
#endif
16+
#pragma once
3717

3818
#include "directx_wrapper.hpp"
3919

@@ -44,9 +24,6 @@ typedef unsigned char UINT8;
4424
#include "errorHelpers.h"
4525
#include "kernelHelpers.h"
4626

47-
// #define log_info(...) printf(__VA_ARGS__)
48-
// #define log_error(...) printf(__VA_ARGS__)
49-
5027
#define NonTestRequire(x, ...) \
5128
do \
5229
{ \
@@ -61,18 +38,18 @@ do \
6138
} \
6239
} while (0)
6340

64-
#define TestRequire(x, ...) \
65-
do \
66-
{ \
67-
if (!(x) ) \
68-
{ \
69-
log_info("\n[assertion failed: %s at %s:%d]\n", #x, __FILE__, __LINE__); \
70-
log_info("ERROR: "); \
71-
log_error(__VA_ARGS__); \
72-
log_info("\n"); \
73-
HarnessD3D10_TestFail(); \
74-
goto Cleanup; \
75-
} \
41+
#define TestRequire(x, ...) \
42+
do \
43+
{ \
44+
if (!(x)) \
45+
{ \
46+
log_info("\n[assertion failed: %s at %s:%d]\n", #x, __FILE__, \
47+
__LINE__); \
48+
log_info("ERROR: "); \
49+
log_error(__VA_ARGS__); \
50+
log_info("\n"); \
51+
goto Cleanup; \
52+
} \
7653
} while (0)
7754

7855
#define TestPrint(...) \
@@ -144,14 +121,6 @@ struct Texture3DSize
144121
};
145122

146123
void HarnessD3D10_Initialize(cl_platform_id platform);
147-
cl_int HarnessD3D10_CreateDevice(IDXGIAdapter* pAdapter, ID3D10Device **ppDevice);
148-
void HarnessD3D10_DestroyDevice();
149-
150-
void HarnessD3D10_TestBegin(const char* fmt, ...);
151-
void HarnessD3D10_TestFail();
152-
void HarnessD3D10_TestEnd();
153-
void HarnessD3D10_TestStats();
154-
155124

156125
void TestAdapterEnumeration(
157126
cl_platform_id platform,
@@ -211,5 +180,3 @@ extern clCreateFromD3D10Texture2DKHR_fn clCreateFromD3D10Texture2DKHR;
211180
extern clCreateFromD3D10Texture3DKHR_fn clCreateFromD3D10Texture3DKHR;
212181
extern clEnqueueAcquireD3D10ObjectsKHR_fn clEnqueueAcquireD3D10ObjectsKHR;
213182
extern clEnqueueReleaseD3D10ObjectsKHR_fn clEnqueueReleaseD3D10ObjectsKHR;
214-
215-
#endif

0 commit comments

Comments
 (0)