mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Proposed patch for bug 14270
This commit is contained in:
committed by
Kévin Petit
parent
b99c6004ce
commit
ce74e803b9
@@ -40,6 +40,13 @@ int context_create(cl_device_id deviceID, cl_context context, cl_command_queue q
|
||||
|
||||
while (deviceWrapper->AdapterNext())
|
||||
{
|
||||
cl_int error;
|
||||
//check if the test can be run on the adapter
|
||||
if (CL_SUCCESS != (error = deviceExistForCLTest(gPlatformIDdetected, adapterType, deviceWrapper->Device(), result, sharedHandle)))
|
||||
{
|
||||
return result.Result();
|
||||
}
|
||||
|
||||
if (surfaceFormat != SURFACE_FORMAT_NV12 && !SurfaceFormatCheck(adapterType, *deviceWrapper, surfaceFormat))
|
||||
{
|
||||
std::string sharedHandleStr = (sharedHandle == SHARED_HANDLE_ENABLED)? "yes": "no";
|
||||
@@ -68,7 +75,6 @@ int context_create(cl_device_id deviceID, cl_context context, cl_command_queue q
|
||||
0,
|
||||
};
|
||||
|
||||
cl_int error;
|
||||
clContextWrapper ctx;
|
||||
switch(functionCreate)
|
||||
{
|
||||
@@ -230,13 +236,20 @@ int context_create(cl_device_id deviceID, cl_context context, cl_command_queue q
|
||||
}
|
||||
}
|
||||
|
||||
if (!deviceWrapper->Status())
|
||||
if (deviceWrapper->Status() != DEVICE_PASS)
|
||||
{
|
||||
std::string adapterName;
|
||||
AdapterToString(adapterType, adapterName);
|
||||
if (deviceWrapper->Status() == DEVICE_FAIL)
|
||||
{
|
||||
log_error("%s init failed\n", adapterName.c_str());
|
||||
result.ResultSub(CResult::TEST_FAIL);
|
||||
return result.Result();
|
||||
}
|
||||
else
|
||||
{
|
||||
log_error("%s init incomplete due to unsupported device\n", adapterName.c_str());
|
||||
result.ResultSub(CResult::TEST_NOTSUPPORTED);
|
||||
}
|
||||
}
|
||||
|
||||
return result.Result();
|
||||
|
||||
@@ -51,6 +51,13 @@ int api_functions(cl_device_id deviceID, cl_context context, cl_command_queue qu
|
||||
//iterates through all devices
|
||||
while (deviceWrapper->AdapterNext())
|
||||
{
|
||||
cl_int error;
|
||||
//check if the test can be run on the adapter
|
||||
if (CL_SUCCESS != (error = deviceExistForCLTest(gPlatformIDdetected, adapterType, deviceWrapper->Device(), result, sharedHandle)))
|
||||
{
|
||||
return result.Result();
|
||||
}
|
||||
|
||||
if (surfaceFormat != SURFACE_FORMAT_NV12 && !SurfaceFormatCheck(adapterType, *deviceWrapper, surfaceFormat))
|
||||
{
|
||||
std::string sharedHandleStr = (sharedHandle == SHARED_HANDLE_ENABLED)? "yes": "no";
|
||||
@@ -81,7 +88,6 @@ int api_functions(cl_device_id deviceID, cl_context context, cl_command_queue qu
|
||||
0,
|
||||
};
|
||||
|
||||
cl_int error;
|
||||
clContextWrapper ctx = clCreateContext(&contextProperties[0], 1, &gDeviceIDdetected, NULL, NULL, &error);
|
||||
if (error != CL_SUCCESS)
|
||||
{
|
||||
@@ -506,13 +512,20 @@ int api_functions(cl_device_id deviceID, cl_context context, cl_command_queue qu
|
||||
}
|
||||
}
|
||||
|
||||
if (!deviceWrapper->Status())
|
||||
if (deviceWrapper->Status() != DEVICE_PASS)
|
||||
{
|
||||
std::string adapterName;
|
||||
AdapterToString(adapterType, adapterName);
|
||||
log_error("%s init failed\n", adapterName.c_str());
|
||||
result.ResultSub(CResult::TEST_FAIL);
|
||||
return result.Result();
|
||||
if (deviceWrapper->Status() == DEVICE_FAIL)
|
||||
{
|
||||
log_error("%s init failed\n", adapterName.c_str());
|
||||
result.ResultSub(CResult::TEST_FAIL);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_error("%s init incomplete due to unsupported device\n", adapterName.c_str());
|
||||
result.ResultSub(CResult::TEST_NOTSUPPORTED);
|
||||
}
|
||||
}
|
||||
|
||||
return result.Result();
|
||||
|
||||
@@ -71,6 +71,13 @@ int kernel_functions(cl_device_id deviceID, cl_context context, cl_command_queue
|
||||
|
||||
while (deviceWrapper->AdapterNext())
|
||||
{
|
||||
cl_int error;
|
||||
//check if the test can be run on the adapter
|
||||
if (CL_SUCCESS != (error = deviceExistForCLTest(gPlatformIDdetected, adapterType, deviceWrapper->Device(), result, sharedHandle)))
|
||||
{
|
||||
return result.Result();
|
||||
}
|
||||
|
||||
if (surfaceFormat != SURFACE_FORMAT_NV12 && !SurfaceFormatCheck(adapterType, *deviceWrapper, surfaceFormat))
|
||||
{
|
||||
std::string sharedHandleStr = (sharedHandle == SHARED_HANDLE_ENABLED)? "yes": "no";
|
||||
@@ -109,7 +116,6 @@ int kernel_functions(cl_device_id deviceID, cl_context context, cl_command_queue
|
||||
0,
|
||||
};
|
||||
|
||||
cl_int error;
|
||||
clContextWrapper ctx = clCreateContext(&contextProperties[0], 1, &gDeviceIDdetected, NULL, NULL, &error);
|
||||
if (error != CL_SUCCESS)
|
||||
{
|
||||
@@ -335,13 +341,20 @@ int kernel_functions(cl_device_id deviceID, cl_context context, cl_command_queue
|
||||
}
|
||||
}
|
||||
|
||||
if (!deviceWrapper->Status())
|
||||
if (deviceWrapper->Status() != DEVICE_PASS)
|
||||
{
|
||||
std::string adapter;
|
||||
AdapterToString(adapterType, adapter);
|
||||
log_error("%s init failed\n", adapter.c_str());
|
||||
std::string adapterName;
|
||||
AdapterToString(adapterType, adapterName);
|
||||
if (deviceWrapper->Status() == DEVICE_FAIL)
|
||||
{
|
||||
log_error("%s init failed\n", adapterName.c_str());
|
||||
result.ResultSub(CResult::TEST_FAIL);
|
||||
return result.Result();
|
||||
}
|
||||
else
|
||||
{
|
||||
log_error("%s init incomplete due to unsupported device\n", adapterName.c_str());
|
||||
result.ResultSub(CResult::TEST_NOTSUPPORTED);
|
||||
}
|
||||
}
|
||||
|
||||
return result.Result();
|
||||
|
||||
@@ -53,6 +53,12 @@ int get_device_ids(cl_device_id deviceID, cl_context context, cl_command_queue q
|
||||
std::vector<void *> mediaDevices;
|
||||
mediaDevices.push_back(deviceWrapper->Device());
|
||||
|
||||
//check if the test can be run on the adapter
|
||||
if (CL_SUCCESS != (error = deviceExistForCLTest(gPlatformIDdetected, adapterType, deviceWrapper->Device(), result)))
|
||||
{
|
||||
return result.Result();
|
||||
}
|
||||
|
||||
cl_uint devicesAllNum = 0;
|
||||
error = clGetDeviceIDsFromDX9MediaAdapterKHR(gPlatformIDdetected, 1, &mediaAdapterTypes[0], &mediaDevices[0],
|
||||
CL_ALL_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR, 0, 0, &devicesAllNum);
|
||||
@@ -140,13 +146,20 @@ int get_device_ids(cl_device_id deviceID, cl_context context, cl_command_queue q
|
||||
}
|
||||
}
|
||||
|
||||
if (!deviceWrapper->Status())
|
||||
if (deviceWrapper->Status() != DEVICE_PASS)
|
||||
{
|
||||
std::string adapter;
|
||||
AdapterToString(adapterType, adapter);
|
||||
log_error("%s init failed\n", adapter.c_str());
|
||||
std::string adapterName;
|
||||
AdapterToString(adapterType, adapterName);
|
||||
if (deviceWrapper->Status() == DEVICE_FAIL)
|
||||
{
|
||||
log_error("%s init failed\n", adapterName.c_str());
|
||||
result.ResultSub(CResult::TEST_FAIL);
|
||||
return result.Result();
|
||||
}
|
||||
else
|
||||
{
|
||||
log_error("%s init incomplete due to unsupported device\n", adapterName.c_str());
|
||||
result.ResultSub(CResult::TEST_NOTSUPPORTED);
|
||||
}
|
||||
}
|
||||
|
||||
return result.Result();
|
||||
|
||||
@@ -40,6 +40,13 @@ int interop_user_sync(cl_device_id deviceID, cl_context context, cl_command_queu
|
||||
|
||||
while (deviceWrapper->AdapterNext())
|
||||
{
|
||||
cl_int error;
|
||||
//check if the test can be run on the adapter
|
||||
if (CL_SUCCESS != (error = deviceExistForCLTest(gPlatformIDdetected, adapterType, deviceWrapper->Device(), result, sharedHandle)))
|
||||
{
|
||||
return result.Result();
|
||||
}
|
||||
|
||||
if (surfaceFormat != SURFACE_FORMAT_NV12 &&
|
||||
!SurfaceFormatCheck(adapterType, *deviceWrapper, surfaceFormat))
|
||||
{
|
||||
@@ -71,7 +78,7 @@ int interop_user_sync(cl_device_id deviceID, cl_context context, cl_command_queu
|
||||
0,
|
||||
};
|
||||
|
||||
cl_int error;
|
||||
|
||||
clContextWrapper ctx;
|
||||
switch(functionCreate)
|
||||
{
|
||||
@@ -258,13 +265,21 @@ int interop_user_sync(cl_device_id deviceID, cl_context context, cl_command_queu
|
||||
}
|
||||
}
|
||||
|
||||
if (!deviceWrapper->Status())
|
||||
if (deviceWrapper->Status() != DEVICE_PASS)
|
||||
{
|
||||
std::string adapterName;
|
||||
AdapterToString(adapterType, adapterName);
|
||||
|
||||
if (deviceWrapper->Status() == DEVICE_FAIL)
|
||||
{
|
||||
log_error("%s init failed\n", adapterName.c_str());
|
||||
result.ResultSub(CResult::TEST_FAIL);
|
||||
return result.Result();
|
||||
}
|
||||
else
|
||||
{
|
||||
log_error("%s init incomplete due to unsupported device\n", adapterName.c_str());
|
||||
result.ResultSub(CResult::TEST_NOTSUPPORTED);
|
||||
}
|
||||
}
|
||||
|
||||
return result.Result();
|
||||
|
||||
@@ -45,6 +45,13 @@ int memory_access(cl_device_id deviceID, cl_context context, cl_command_queue qu
|
||||
//iterates through all devices
|
||||
while (deviceWrapper->AdapterNext())
|
||||
{
|
||||
cl_int error;
|
||||
//check if the test can be run on the adapter
|
||||
if (CL_SUCCESS != (error = deviceExistForCLTest(gPlatformIDdetected, adapterType, deviceWrapper->Device(), result, sharedHandle)))
|
||||
{
|
||||
return result.Result();
|
||||
}
|
||||
|
||||
if (surfaceFormat != SURFACE_FORMAT_NV12 && !SurfaceFormatCheck(adapterType, *deviceWrapper, surfaceFormat))
|
||||
{
|
||||
std::string sharedHandleStr = (sharedHandle == SHARED_HANDLE_ENABLED)? "yes": "no";
|
||||
@@ -81,7 +88,6 @@ int memory_access(cl_device_id deviceID, cl_context context, cl_command_queue qu
|
||||
0,
|
||||
};
|
||||
|
||||
cl_int error;
|
||||
clContextWrapper ctx = clCreateContext(&contextProperties[0], 1, &gDeviceIDdetected, NULL, NULL, &error);
|
||||
if (error != CL_SUCCESS)
|
||||
{
|
||||
@@ -357,13 +363,20 @@ int memory_access(cl_device_id deviceID, cl_context context, cl_command_queue qu
|
||||
}
|
||||
}
|
||||
|
||||
if (!deviceWrapper->Status())
|
||||
if (deviceWrapper->Status() != DEVICE_PASS)
|
||||
{
|
||||
std::string adapterName;
|
||||
AdapterToString(adapterType, adapterName);
|
||||
if (deviceWrapper->Status() == DEVICE_FAIL)
|
||||
{
|
||||
log_error("%s init failed\n", adapterName.c_str());
|
||||
result.ResultSub(CResult::TEST_FAIL);
|
||||
return result.Result();
|
||||
}
|
||||
else
|
||||
{
|
||||
log_error("%s init incomplete due to unsupported device\n", adapterName.c_str());
|
||||
result.ResultSub(CResult::TEST_NOTSUPPORTED);
|
||||
}
|
||||
}
|
||||
|
||||
return result.Result();
|
||||
|
||||
@@ -65,13 +65,19 @@ int other_data_types(cl_device_id deviceID, cl_context context, cl_command_queue
|
||||
|
||||
while (deviceWrapper->AdapterNext())
|
||||
{
|
||||
cl_int error;
|
||||
//check if the test can be run on the adapter
|
||||
if (CL_SUCCESS != (error = deviceExistForCLTest(gPlatformIDdetected, adapterType, deviceWrapper->Device(), result, sharedHandle)))
|
||||
{
|
||||
return result.Result();
|
||||
}
|
||||
|
||||
cl_context_properties contextProperties[] = {
|
||||
CL_CONTEXT_PLATFORM, (cl_context_properties)gPlatformIDdetected,
|
||||
AdapterTypeToContextInfo(adapterType), (cl_context_properties)deviceWrapper->Device(),
|
||||
0,
|
||||
};
|
||||
|
||||
cl_int error;
|
||||
clContextWrapper ctx = clCreateContext(&contextProperties[0], 1, &gDeviceIDdetected, NULL, NULL, &error);
|
||||
if (error != CL_SUCCESS)
|
||||
{
|
||||
@@ -419,13 +425,20 @@ int other_data_types(cl_device_id deviceID, cl_context context, cl_command_queue
|
||||
}
|
||||
}
|
||||
|
||||
if (!deviceWrapper->Status())
|
||||
if (deviceWrapper->Status() != DEVICE_PASS)
|
||||
{
|
||||
std::string adapter;
|
||||
AdapterToString(adapterType, adapter);
|
||||
log_error("%s init failed\n", adapter.c_str());
|
||||
std::string adapterName;
|
||||
AdapterToString(adapterType, adapterName);
|
||||
if (deviceWrapper->Status() == DEVICE_FAIL)
|
||||
{
|
||||
log_error("%s init failed\n", adapterName.c_str());
|
||||
result.ResultSub(CResult::TEST_FAIL);
|
||||
return result.Result();
|
||||
}
|
||||
else
|
||||
{
|
||||
log_error("%s init incomplete due to unsupported device\n", adapterName.c_str());
|
||||
result.ResultSub(CResult::TEST_NOTSUPPORTED);
|
||||
}
|
||||
}
|
||||
|
||||
return result.Result();
|
||||
|
||||
@@ -1935,3 +1935,36 @@ float convert_half_to_float( unsigned short halfValue )
|
||||
outFloat.bits = ( sign << 31 ) | ( exponent << 23 ) | mantissa;
|
||||
return outFloat.floatValue;
|
||||
}
|
||||
|
||||
cl_int deviceExistForCLTest(cl_platform_id platform,
|
||||
cl_dx9_media_adapter_type_khr media_adapters_type,
|
||||
void *media_adapters,
|
||||
CResult &result,
|
||||
TSharedHandleType sharedHandle /*default SHARED_HANDLE_ENABLED*/
|
||||
)
|
||||
{
|
||||
cl_int _error;
|
||||
cl_uint devicesAllNum = 0;
|
||||
std::string sharedHandleStr = (sharedHandle == SHARED_HANDLE_ENABLED)? "yes": "no";
|
||||
std::string adapterStr;
|
||||
AdapterToString(media_adapters_type, adapterStr);
|
||||
|
||||
_error = clGetDeviceIDsFromDX9MediaAdapterKHR(platform, 1,
|
||||
&media_adapters_type, &media_adapters, CL_PREFERRED_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR, 0, 0, &devicesAllNum);
|
||||
|
||||
if (_error != CL_SUCCESS)
|
||||
{
|
||||
if(_error != CL_DEVICE_NOT_FOUND)
|
||||
{
|
||||
log_error("clGetDeviceIDsFromDX9MediaAdapterKHR failed: %s\n", IGetErrorString(_error));
|
||||
result.ResultSub(CResult::TEST_ERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info("Skipping test case, device type is not supported by a device (adapter type: %s, shared handle: %s)\n", adapterStr.c_str(), sharedHandleStr.c_str());
|
||||
result.ResultSub(CResult::TEST_NOTSUPPORTED);
|
||||
}
|
||||
}
|
||||
|
||||
return _error;
|
||||
}
|
||||
|
||||
@@ -16,15 +16,18 @@
|
||||
#ifndef __UTILS_KHR_MEDIA_H
|
||||
#define __UTILS_KHR_MEDIA_H
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "wrappers.h"
|
||||
#include "CL/cl_dx9_media_sharing.h"
|
||||
|
||||
#include "../../test_common/harness/typeWrappers.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
||||
|
||||
|
||||
extern clGetDeviceIDsFromDX9MediaAdapterKHR_fn clGetDeviceIDsFromDX9MediaAdapterKHR;
|
||||
extern clCreateFromDX9MediaSurfaceKHR_fn clCreateFromDX9MediaSurfaceKHR;
|
||||
@@ -168,4 +171,5 @@ cl_ushort convert_float_to_half( float f );
|
||||
float convert_half_to_float( unsigned short halfValue );
|
||||
int DetectFloatToHalfRoundingMode( cl_command_queue );
|
||||
|
||||
cl_int deviceExistForCLTest(cl_platform_id platform,cl_dx9_media_adapter_type_khr media_adapters_type,void *media_adapters,CResult &result,TSharedHandleType sharedHandle=SHARED_HANDLE_DISABLED);
|
||||
#endif // __UTILS_KHR_MEDIA_H
|
||||
|
||||
@@ -141,7 +141,7 @@ CDeviceWrapper::~CDeviceWrapper()
|
||||
|
||||
#if defined(_WIN32)
|
||||
CD3D9Wrapper::CD3D9Wrapper():
|
||||
_d3d9(NULL), _d3dDevice(NULL), _status(true), _adapterIdx(0), _adapterFound(false)
|
||||
_d3d9(NULL), _d3dDevice(NULL), _status(DEVICE_PASS), _adapterIdx(0), _adapterFound(false)
|
||||
{
|
||||
WindowInit();
|
||||
|
||||
@@ -149,7 +149,7 @@ _d3d9(NULL), _d3dDevice(NULL), _status(true), _adapterIdx(0), _adapterFound(fals
|
||||
if (!_d3d9)
|
||||
{
|
||||
log_error("Direct3DCreate9 failed\n");
|
||||
_status = false;
|
||||
_status = DEVICE_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,16 +169,16 @@ void CD3D9Wrapper::Destroy()
|
||||
_d3dDevice = 0;
|
||||
}
|
||||
|
||||
bool CD3D9Wrapper::Init()
|
||||
cl_int CD3D9Wrapper::Init()
|
||||
{
|
||||
if (!WindowHandle())
|
||||
{
|
||||
log_error("D3D9: Window is not created\n");
|
||||
_status = false;
|
||||
return false;
|
||||
_status = DEVICE_FAIL;
|
||||
return DEVICE_FAIL;
|
||||
}
|
||||
|
||||
if(!_d3d9 || !_status || !_adapterFound)
|
||||
if(!_d3d9 || DEVICE_PASS != _status || !_adapterFound)
|
||||
return false;
|
||||
|
||||
_d3d9->GetAdapterDisplayMode(_adapterIdx - 1, &_d3ddm);
|
||||
@@ -201,8 +201,8 @@ bool CD3D9Wrapper::Init()
|
||||
processingType, &d3dParams, &_d3dDevice) ) )
|
||||
{
|
||||
log_error("CreateDevice failed\n");
|
||||
_status = false;
|
||||
return false;
|
||||
_status = DEVICE_FAIL;
|
||||
return DEVICE_FAIL;
|
||||
}
|
||||
|
||||
_d3dDevice->BeginScene();
|
||||
@@ -232,14 +232,14 @@ D3DADAPTER_IDENTIFIER9 CD3D9Wrapper::Adapter()
|
||||
return _adapter;
|
||||
}
|
||||
|
||||
bool CD3D9Wrapper::Status() const
|
||||
TDeviceStatus CD3D9Wrapper::Status() const
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
|
||||
bool CD3D9Wrapper::AdapterNext()
|
||||
{
|
||||
if (!_status)
|
||||
if (DEVICE_PASS != _status)
|
||||
return false;
|
||||
|
||||
_adapterFound = false;
|
||||
@@ -253,7 +253,7 @@ bool CD3D9Wrapper::AdapterNext()
|
||||
if(FAILED(_d3d9->GetAdapterIdentifier(_adapterIdx - 1, 0, &_adapter)))
|
||||
{
|
||||
log_error("D3D9: GetAdapterIdentifier failed\n");
|
||||
_status = false;
|
||||
_status = DEVICE_FAIL;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ bool CD3D9Wrapper::AdapterNext()
|
||||
Destroy();
|
||||
if(!Init())
|
||||
{
|
||||
_status = false;
|
||||
_status = DEVICE_FAIL;
|
||||
_adapterFound = false;
|
||||
}
|
||||
break;
|
||||
@@ -278,7 +278,7 @@ unsigned int CD3D9Wrapper::AdapterIdx() const
|
||||
|
||||
|
||||
CD3D9ExWrapper::CD3D9ExWrapper():
|
||||
_d3d9Ex(NULL), _d3dDeviceEx(NULL), _status(true), _adapterIdx(0), _adapterFound(false)
|
||||
_d3d9Ex(NULL), _d3dDeviceEx(NULL), _status(DEVICE_PASS), _adapterIdx(0), _adapterFound(false)
|
||||
{
|
||||
WindowInit();
|
||||
|
||||
@@ -286,7 +286,7 @@ _d3d9Ex(NULL), _d3dDeviceEx(NULL), _status(true), _adapterIdx(0), _adapterFound(
|
||||
if (FAILED(result) || !_d3d9Ex)
|
||||
{
|
||||
log_error("Direct3DCreate9Ex failed\n");
|
||||
_status = false;
|
||||
_status = DEVICE_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,17 +319,17 @@ D3DADAPTER_IDENTIFIER9 CD3D9ExWrapper::Adapter()
|
||||
return _adapter;
|
||||
}
|
||||
|
||||
bool CD3D9ExWrapper::Init()
|
||||
cl_int CD3D9ExWrapper::Init()
|
||||
{
|
||||
if (!WindowHandle())
|
||||
{
|
||||
log_error("D3D9EX: Window is not created\n");
|
||||
_status = false;
|
||||
return false;
|
||||
_status = DEVICE_FAIL;
|
||||
return DEVICE_FAIL;
|
||||
}
|
||||
|
||||
if(!_d3d9Ex || !_status || !_adapterFound)
|
||||
return false;
|
||||
if(!_d3d9Ex || DEVICE_FAIL == _status || !_adapterFound)
|
||||
return DEVICE_FAIL;
|
||||
|
||||
RECT rect;
|
||||
GetClientRect(WindowHandle(),&rect);
|
||||
@@ -353,15 +353,15 @@ bool CD3D9ExWrapper::Init()
|
||||
processingType, &d3dParams, NULL, &_d3dDeviceEx) ) )
|
||||
{
|
||||
log_error("CreateDeviceEx failed\n");
|
||||
_status = false;
|
||||
return false;
|
||||
_status = DEVICE_FAIL;
|
||||
return DEVICE_FAIL;
|
||||
}
|
||||
|
||||
_d3dDeviceEx->BeginScene();
|
||||
_d3dDeviceEx->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);
|
||||
_d3dDeviceEx->EndScene();
|
||||
|
||||
return true;
|
||||
return DEVICE_PASS;
|
||||
}
|
||||
|
||||
void CD3D9ExWrapper::Destroy()
|
||||
@@ -371,14 +371,14 @@ void CD3D9ExWrapper::Destroy()
|
||||
_d3dDeviceEx = 0;
|
||||
}
|
||||
|
||||
bool CD3D9ExWrapper::Status() const
|
||||
TDeviceStatus CD3D9ExWrapper::Status() const
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
|
||||
bool CD3D9ExWrapper::AdapterNext()
|
||||
{
|
||||
if (!_status)
|
||||
if (DEVICE_FAIL == _status)
|
||||
return false;
|
||||
|
||||
_adapterFound = false;
|
||||
@@ -392,7 +392,7 @@ bool CD3D9ExWrapper::AdapterNext()
|
||||
if(FAILED(_d3d9Ex->GetAdapterIdentifier(_adapterIdx - 1, 0, &_adapter)))
|
||||
{
|
||||
log_error("D3D9EX: GetAdapterIdentifier failed\n");
|
||||
_status = false;
|
||||
_status = DEVICE_FAIL;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -400,8 +400,8 @@ bool CD3D9ExWrapper::AdapterNext()
|
||||
Destroy();
|
||||
if(!Init())
|
||||
{
|
||||
_status = false;
|
||||
_adapterFound = false;
|
||||
_status = DEVICE_FAIL;
|
||||
_adapterFound = _status;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -416,7 +416,7 @@ unsigned int CD3D9ExWrapper::AdapterIdx() const
|
||||
}
|
||||
|
||||
CDXVAWrapper::CDXVAWrapper():
|
||||
_dxvaDevice(NULL), _status(true), _adapterFound(false)
|
||||
_dxvaDevice(NULL), _status(DEVICE_PASS), _adapterFound(false)
|
||||
{
|
||||
_status = _d3d9.Status();
|
||||
}
|
||||
@@ -431,19 +431,24 @@ void * CDXVAWrapper::Device() const
|
||||
return _dxvaDevice;
|
||||
}
|
||||
|
||||
bool CDXVAWrapper::Status() const
|
||||
TDeviceStatus CDXVAWrapper::Status() const
|
||||
{
|
||||
return _status && _d3d9.Status();
|
||||
if(_status == DEVICE_FAIL || _d3d9.Status() == DEVICE_FAIL)
|
||||
return DEVICE_FAIL;
|
||||
else if(_status == DEVICE_NOTSUPPORTED || _d3d9.Status() == DEVICE_NOTSUPPORTED)
|
||||
return DEVICE_NOTSUPPORTED;
|
||||
else
|
||||
return DEVICE_PASS;
|
||||
}
|
||||
|
||||
bool CDXVAWrapper::AdapterNext()
|
||||
{
|
||||
if (!_status)
|
||||
if (DEVICE_PASS != _status)
|
||||
return false;
|
||||
|
||||
_adapterFound = _d3d9.AdapterNext();
|
||||
_status = _d3d9.Status();
|
||||
if (!_status)
|
||||
if (DEVICE_PASS != _status)
|
||||
{
|
||||
_adapterFound = false;
|
||||
return false;
|
||||
@@ -454,7 +459,7 @@ bool CDXVAWrapper::AdapterNext()
|
||||
|
||||
DXVAHDDestroy();
|
||||
_status = DXVAHDInit();
|
||||
if (!_status)
|
||||
if (DEVICE_PASS != _status)
|
||||
{
|
||||
_adapterFound = false;
|
||||
return false;
|
||||
@@ -463,10 +468,10 @@ bool CDXVAWrapper::AdapterNext()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDXVAWrapper::DXVAHDInit()
|
||||
TDeviceStatus CDXVAWrapper::DXVAHDInit()
|
||||
{
|
||||
if (!_status || !_d3d9.Status() || !_adapterFound)
|
||||
return false;
|
||||
if ((_status == DEVICE_FAIL) || (_d3d9.Status() == DEVICE_FAIL) || !_adapterFound)
|
||||
return DEVICE_FAIL;
|
||||
|
||||
DXVAHD_RATIONAL fps = { VIDEO_FPS, 1 };
|
||||
|
||||
@@ -480,20 +485,27 @@ bool CDXVAWrapper::DXVAHDInit()
|
||||
desc.OutputHeight = WindowHeight();
|
||||
|
||||
#ifdef USE_SOFTWARE_PLUGIN
|
||||
_status = false;
|
||||
return false;
|
||||
_status = DEVICE_FAIL;
|
||||
return DEVICE_FAIL;
|
||||
#endif
|
||||
|
||||
HRESULT hr = DXVAHD_CreateDevice(static_cast<IDirect3DDevice9Ex *>(_d3d9.Device()),
|
||||
&desc, DXVAHD_DEVICE_USAGE_PLAYBACK_NORMAL, NULL, &_dxvaDevice);
|
||||
if(FAILED(hr))
|
||||
{
|
||||
if (hr == E_NOINTERFACE)
|
||||
{
|
||||
log_error("DXVAHD_CreateDevice skipped due to no supported devices!\n");
|
||||
_status = DEVICE_NOTSUPPORTED;
|
||||
}
|
||||
else
|
||||
{
|
||||
log_error("DXVAHD_CreateDevice failed\n");
|
||||
_status = false;
|
||||
return false;
|
||||
_status = DEVICE_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return _status;
|
||||
}
|
||||
|
||||
void CDXVAWrapper::DXVAHDDestroy()
|
||||
|
||||
@@ -18,10 +18,37 @@
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <d3d9.h>
|
||||
#if defined (__MINGW32__)
|
||||
#include <rpcsal.h>
|
||||
typedef unsigned char UINT8;
|
||||
#define __out
|
||||
#define __in
|
||||
#define __inout
|
||||
#define __out_bcount(size)
|
||||
#define __out_bcount_opt(size)
|
||||
#define __in_opt
|
||||
#define __in_ecount(size)
|
||||
#define __in_ecount_opt(size)
|
||||
#define __out_opt
|
||||
#define __out_ecount(size)
|
||||
#define __out_ecount_opt(size)
|
||||
#define __in_bcount_opt(size)
|
||||
#define __inout_opt
|
||||
#define __inout_bcount(size)
|
||||
#define __in_bcount(size)
|
||||
#define __deref_out
|
||||
#endif
|
||||
#include <dxvahd.h>
|
||||
#include <tchar.h>
|
||||
#endif
|
||||
|
||||
enum TDeviceStatus
|
||||
{
|
||||
DEVICE_NOTSUPPORTED,
|
||||
DEVICE_PASS,
|
||||
DEVICE_FAIL,
|
||||
};
|
||||
|
||||
class CDeviceWrapper {
|
||||
public:
|
||||
enum TAccelerationType
|
||||
@@ -36,7 +63,7 @@ public:
|
||||
virtual bool AdapterNext() = 0;
|
||||
virtual unsigned int AdapterIdx() const = 0;
|
||||
virtual void *Device() const = 0;
|
||||
virtual bool Status() const = 0;
|
||||
virtual TDeviceStatus Status() const = 0;
|
||||
virtual void *D3D() const = 0;
|
||||
|
||||
#if defined(_WIN32)
|
||||
@@ -81,7 +108,7 @@ public:
|
||||
virtual bool AdapterNext();
|
||||
virtual unsigned int AdapterIdx() const;
|
||||
virtual void *Device() const;
|
||||
virtual bool Status() const;
|
||||
virtual TDeviceStatus Status() const;
|
||||
virtual void *D3D() const;
|
||||
|
||||
private:
|
||||
@@ -89,13 +116,13 @@ private:
|
||||
LPDIRECT3DDEVICE9 _d3dDevice;
|
||||
D3DDISPLAYMODE _d3ddm;
|
||||
D3DADAPTER_IDENTIFIER9 _adapter;
|
||||
bool _status;
|
||||
TDeviceStatus _status;
|
||||
unsigned int _adapterIdx;
|
||||
bool _adapterFound;
|
||||
|
||||
D3DFORMAT Format();
|
||||
D3DADAPTER_IDENTIFIER9 Adapter();
|
||||
bool Init();
|
||||
int Init();
|
||||
void Destroy();
|
||||
};
|
||||
|
||||
@@ -107,7 +134,7 @@ public:
|
||||
virtual bool AdapterNext();
|
||||
virtual unsigned int AdapterIdx() const;
|
||||
virtual void *Device() const;
|
||||
virtual bool Status() const;
|
||||
virtual TDeviceStatus Status() const;
|
||||
virtual void *D3D() const;
|
||||
|
||||
private:
|
||||
@@ -115,13 +142,13 @@ private:
|
||||
LPDIRECT3DDEVICE9EX _d3dDeviceEx;
|
||||
D3DDISPLAYMODEEX _d3ddmEx;
|
||||
D3DADAPTER_IDENTIFIER9 _adapter;
|
||||
bool _status;
|
||||
TDeviceStatus _status;
|
||||
unsigned int _adapterIdx;
|
||||
bool _adapterFound;
|
||||
|
||||
D3DFORMAT Format();
|
||||
D3DADAPTER_IDENTIFIER9 Adapter();
|
||||
bool Init();
|
||||
int Init();
|
||||
void Destroy();
|
||||
};
|
||||
|
||||
@@ -133,21 +160,21 @@ public:
|
||||
virtual bool AdapterNext();
|
||||
virtual unsigned int AdapterIdx() const;
|
||||
virtual void *Device() const;
|
||||
virtual bool Status() const;
|
||||
virtual TDeviceStatus Status() const;
|
||||
virtual void *D3D() const;
|
||||
const CD3D9ExWrapper &D3D9() const;
|
||||
|
||||
private:
|
||||
CD3D9ExWrapper _d3d9;
|
||||
IDXVAHD_Device *_dxvaDevice;
|
||||
bool _status;
|
||||
TDeviceStatus _status;
|
||||
bool _adapterFound;
|
||||
|
||||
static const D3DFORMAT RENDER_TARGET_FORMAT;
|
||||
static const D3DFORMAT VIDEO_FORMAT;
|
||||
static const unsigned int VIDEO_FPS;
|
||||
|
||||
bool DXVAHDInit();
|
||||
TDeviceStatus DXVAHDInit();
|
||||
void DXVAHDDestroy();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user