mirror of
https://github.com/Kbz-8/Pulse.git
synced 2026-01-10 15:03:34 +00:00
improve image creation tests and windows opengl ci
This commit is contained in:
36
.github/workflows/opengl-test-windows.yml
vendored
36
.github/workflows/opengl-test-windows.yml
vendored
@@ -31,22 +31,30 @@ jobs:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download Mesa
|
||||
run: |
|
||||
curl -LO https://github.com/pal1000/mesa-dist-win/releases/download/23.3.1/mesa3d-23.3.1-release-msvc.7z
|
||||
7z x mesa3d-23.3.1-release-msvc.7z -omesa
|
||||
- name: Install 7zip
|
||||
run: choco install -y 7zip
|
||||
|
||||
- name: Set Mesa in PATH
|
||||
run: echo "$env:GITHUB_WORKSPACE\\mesa\\x64" | Out-File -Append -FilePath $env:GITHUB_PATH
|
||||
|
||||
- name: Set Mesa env
|
||||
- name: Download Mesa (prebuilt, MSVC x64)
|
||||
shell: pwsh
|
||||
run: |
|
||||
echo "LIBGL_ALWAYS_SOFTWARE=1" >> $env:GITHUB_ENV
|
||||
echo "MESA_GL_VERSION_OVERRIDE=4.3" >> $env:GITHUB_ENV
|
||||
echo "MESA_GLES_VERSION_OVERRIDE=3.2" >> $env:GITHUB_ENV
|
||||
echo "LIBGL_DEBUG=verbose" >> $env:GITHUB_ENV
|
||||
echo "EGL_LOG_LEVEL=debug" >> $env:GITHUB_ENV
|
||||
echo "MESA_VERBOSE=all" >> $env:GITHUB_ENV
|
||||
$ver = "24.3.4"
|
||||
$uri = "https://github.com/pal1000/mesa-dist-win/releases/download/$ver/mesa3d-$ver-release-msvc.7z"
|
||||
Invoke-WebRequest $uri -OutFile "$env:RUNNER_TEMP\mesa.7z"
|
||||
7z x "$env:RUNNER_TEMP\mesa.7z" "-o$env:RUNNER_TEMP\mesa" -y
|
||||
|
||||
- name: Drop Mesa next to the exe (EGL headless)
|
||||
shell: pwsh
|
||||
run: |
|
||||
$dll_dir = "$env:RUNNER_TEMP\mesa\x64"
|
||||
Copy-Item "$dll_dir\opengl32.dll" -Destination "build\Release"
|
||||
Copy-Item "$dll_dir\libgallium_wgl.dll" -Destination "build\Release"
|
||||
Copy-Item "$dll_dir\libEGL.dll" -Destination "build\Release"
|
||||
# If you use OSMesa (Mesa < 25.1): also copy osmesa.dll
|
||||
|
||||
- name: Force llvmpipe + core 4.5
|
||||
run: |
|
||||
setx GALLIUM_DRIVER llvmpipe
|
||||
setx MESA_GL_VERSION_OVERRIDE 4.5
|
||||
|
||||
# Force xmake to a specific folder (for cache)
|
||||
- name: Set xmake env
|
||||
|
||||
@@ -76,7 +76,7 @@ typedef enum PulseShaderFormatsBits
|
||||
PULSE_SHADER_FORMAT_METALLIB_BIT = PULSE_BIT(3), // Can be used by Metal backend
|
||||
PULSE_SHADER_FORMAT_WGSL_BIT = PULSE_BIT(4), // Can be used by WebGPU backend
|
||||
PULSE_SHADER_FORMAT_GLSL_BIT = PULSE_BIT(5), // Can be used by OpenGL / OpenGL_ES backend
|
||||
PULSE_SHADER_FORMAT_DXBC_BIT = PULSE_BIT(6), // Can be used by D3D11 backend
|
||||
PULSE_SHADER_FORMAT_DXBC_BIT = PULSE_BIT(6), // Can be used by D3D11 backend
|
||||
// More to come
|
||||
} PulseShaderFormatsBits;
|
||||
typedef PulseFlags PulseShaderFormatsFlags;
|
||||
|
||||
@@ -92,7 +92,7 @@ PulseImage OpenGLCreateImageTryAndFail(PulseDevice device, const PulseImageCreat
|
||||
|
||||
if(image_type == GL_INVALID_ENUM)
|
||||
{
|
||||
if(PULSE_IS_BACKEND_LOW_LEVEL_DEBUG(device->backend))
|
||||
if(PULSE_IS_BACKEND_LOW_LEVEL_DEBUG(device->backend) && !try_and_fail)
|
||||
PulseLogErrorFmt(device->backend, "%s image type is not supported", device->backend->backend == PULSE_BACKEND_OPENGL ? "(OpenGL)" : "(OpenGL ES)");
|
||||
PulseSetInternalError(PULSE_ERROR_INITIALIZATION_FAILED);
|
||||
free(opengl_image);
|
||||
@@ -101,7 +101,7 @@ PulseImage OpenGLCreateImageTryAndFail(PulseDevice device, const PulseImageCreat
|
||||
}
|
||||
if(image_format == GL_INVALID_ENUM)
|
||||
{
|
||||
if(PULSE_IS_BACKEND_LOW_LEVEL_DEBUG(device->backend))
|
||||
if(PULSE_IS_BACKEND_LOW_LEVEL_DEBUG(device->backend) && !try_and_fail)
|
||||
PulseLogErrorFmt(device->backend, "%s image format is not supported", device->backend->backend == PULSE_BACKEND_OPENGL ? "(OpenGL)" : "(OpenGL ES)");
|
||||
PulseSetInternalError(PULSE_ERROR_INVALID_IMAGE_FORMAT);
|
||||
free(opengl_image);
|
||||
|
||||
@@ -215,10 +215,11 @@ PulseDevice WebGPUCreateDevice(PulseBackend backend, PulseDevice* forbiden_devic
|
||||
|
||||
#ifndef PULSE_PLAT_WASM
|
||||
WGPUFeatureName features[] = {
|
||||
WGPUNativeFeature_TextureAdapterSpecificFormatFeatures,
|
||||
(WGPUFeatureName)WGPUNativeFeature_TextureAdapterSpecificFormatFeatures,
|
||||
WGPUFeatureName_TextureCompressionBC,
|
||||
};
|
||||
descriptor.requiredFeatures = features;
|
||||
descriptor.requiredFeatureCount = 1;
|
||||
descriptor.requiredFeatureCount = PULSE_SIZEOF_ARRAY(features);
|
||||
#endif
|
||||
|
||||
WGPURequestDeviceCallbackInfo device_callback = { 0 };
|
||||
|
||||
@@ -176,26 +176,11 @@ bool WebGPUIsImageFormatValid(PulseDevice device, PulseImageFormat format, Pulse
|
||||
wgpu_usage |= WGPUTextureUsage_StorageBinding | WGPUTextureUsage_CopySrc | WGPUTextureUsage_CopyDst;
|
||||
|
||||
if(wgpu_format == WGPUTextureFormat_Undefined)
|
||||
{
|
||||
if(PULSE_IS_BACKEND_LOW_LEVEL_DEBUG(device->backend))
|
||||
PulseLogError(device->backend, "(WebGPU) unsupported image format");
|
||||
PulseSetInternalError(PULSE_ERROR_INVALID_IMAGE_FORMAT);
|
||||
return false;
|
||||
}
|
||||
if(wgpu_usage == WGPUTextureUsage_None)
|
||||
{
|
||||
if(PULSE_IS_BACKEND_LOW_LEVEL_DEBUG(device->backend))
|
||||
PulseLogError(device->backend, "(WebGPU) unsupported image usage");
|
||||
PulseSetInternalError(PULSE_ERROR_INVALID_IMAGE_USAGE);
|
||||
return false;
|
||||
}
|
||||
if(dimension == WGPUTextureDimension_Undefined)
|
||||
{
|
||||
if(PULSE_IS_BACKEND_LOW_LEVEL_DEBUG(device->backend))
|
||||
PulseLogError(device->backend, "(WebGPU) unsupported image type");
|
||||
PulseSetInternalError(PULSE_ERROR_INVALID_IMAGE_FORMAT);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
130
Tests/Image.c
130
Tests/Image.c
@@ -10,103 +10,45 @@ void TestImageCreation()
|
||||
PulseDevice device;
|
||||
SetupDevice(backend, &device);
|
||||
|
||||
{
|
||||
PulseImageCreateInfo image_create_info = { 0 };
|
||||
image_create_info.type = PULSE_IMAGE_TYPE_2D;
|
||||
image_create_info.format = PULSE_IMAGE_FORMAT_R8G8B8A8_UNORM;
|
||||
image_create_info.usage = PULSE_IMAGE_USAGE_STORAGE_READ;
|
||||
image_create_info.width = 256;
|
||||
image_create_info.height = 256;
|
||||
image_create_info.layer_count_or_depth = 1;
|
||||
PulseImage image = PulseCreateImage(device, &image_create_info);
|
||||
TEST_ASSERT_NOT_EQUAL_MESSAGE(image, PULSE_NULL_HANDLE, PulseVerbaliseErrorType(PulseGetLastErrorType()));
|
||||
PulseDestroyImage(device, image);
|
||||
}
|
||||
{
|
||||
PulseImageCreateInfo image_create_info = { 0 };
|
||||
image_create_info.type = PULSE_IMAGE_TYPE_2D_ARRAY;
|
||||
image_create_info.format = PULSE_IMAGE_FORMAT_R8G8B8A8_UNORM;
|
||||
image_create_info.usage = PULSE_IMAGE_USAGE_STORAGE_READ;
|
||||
image_create_info.width = 256;
|
||||
image_create_info.height = 256;
|
||||
image_create_info.layer_count_or_depth = 1;
|
||||
PulseImage image = PulseCreateImage(device, &image_create_info);
|
||||
TEST_ASSERT_NOT_EQUAL_MESSAGE(image, PULSE_NULL_HANDLE, PulseVerbaliseErrorType(PulseGetLastErrorType()));
|
||||
PulseDestroyImage(device, image);
|
||||
}
|
||||
PulseImageUsageFlags usages[] = {
|
||||
PULSE_IMAGE_USAGE_STORAGE_READ,
|
||||
PULSE_IMAGE_USAGE_STORAGE_WRITE,
|
||||
PULSE_IMAGE_USAGE_STORAGE_SIMULTANEOUS_READWRITE,
|
||||
PULSE_IMAGE_USAGE_STORAGE_WRITE | PULSE_IMAGE_USAGE_STORAGE_READ,
|
||||
};
|
||||
|
||||
for(unsigned int format = 0; format < (unsigned int)PULSE_IMAGE_FORMAT_MAX_ENUM; format++)
|
||||
{
|
||||
PulseImageCreateInfo image_create_info = { 0 };
|
||||
image_create_info.type = PULSE_IMAGE_TYPE_3D;
|
||||
image_create_info.format = PULSE_IMAGE_FORMAT_R8G8B8A8_UNORM;
|
||||
image_create_info.usage = PULSE_IMAGE_USAGE_STORAGE_READ;
|
||||
image_create_info.width = 256;
|
||||
image_create_info.height = 256;
|
||||
image_create_info.layer_count_or_depth = 1;
|
||||
PulseImage image = PulseCreateImage(device, &image_create_info);
|
||||
TEST_ASSERT_NOT_EQUAL_MESSAGE(image, PULSE_NULL_HANDLE, PulseVerbaliseErrorType(PulseGetLastErrorType()));
|
||||
PulseDestroyImage(device, image);
|
||||
}
|
||||
for(unsigned int type = 0; type < (unsigned int)PULSE_IMAGE_TYPE_MAX_ENUM; type++)
|
||||
{
|
||||
for(unsigned int usages = 0; usages < 4; usages++)
|
||||
{
|
||||
PulseImageCreateInfo image_create_info = { 0 };
|
||||
image_create_info.type = type;
|
||||
image_create_info.format = format;
|
||||
image_create_info.usage = usages;
|
||||
image_create_info.width = 256;
|
||||
image_create_info.height = 256;
|
||||
image_create_info.layer_count_or_depth = (type == PULSE_IMAGE_TYPE_CUBE || type == PULSE_IMAGE_TYPE_CUBE_ARRAY) ? 6 : 1;
|
||||
|
||||
{
|
||||
PulseImageCreateInfo image_create_info = { 0 };
|
||||
image_create_info.type = PULSE_IMAGE_TYPE_CUBE;
|
||||
image_create_info.format = PULSE_IMAGE_FORMAT_R8G8B8A8_UNORM;
|
||||
image_create_info.usage = PULSE_IMAGE_USAGE_STORAGE_READ;
|
||||
image_create_info.width = 256;
|
||||
image_create_info.height = 256;
|
||||
image_create_info.layer_count_or_depth = 6;
|
||||
PulseImage image = PulseCreateImage(device, &image_create_info);
|
||||
TEST_ASSERT_NOT_EQUAL_MESSAGE(image, PULSE_NULL_HANDLE, PulseVerbaliseErrorType(PulseGetLastErrorType()));
|
||||
PulseDestroyImage(device, image);
|
||||
}
|
||||
{
|
||||
PulseImageCreateInfo image_create_info = { 0 };
|
||||
image_create_info.type = PULSE_IMAGE_TYPE_CUBE_ARRAY;
|
||||
image_create_info.format = PULSE_IMAGE_FORMAT_R8G8B8A8_UNORM;
|
||||
image_create_info.usage = PULSE_IMAGE_USAGE_STORAGE_READ;
|
||||
image_create_info.width = 256;
|
||||
image_create_info.height = 256;
|
||||
image_create_info.layer_count_or_depth = 12;
|
||||
PulseImage image = PulseCreateImage(device, &image_create_info);
|
||||
TEST_ASSERT_NOT_EQUAL_MESSAGE(image, PULSE_NULL_HANDLE, PulseVerbaliseErrorType(PulseGetLastErrorType()));
|
||||
PulseDestroyImage(device, image);
|
||||
}
|
||||
{
|
||||
PulseImageCreateInfo image_create_info = { 0 };
|
||||
image_create_info.type = PULSE_IMAGE_TYPE_2D;
|
||||
image_create_info.format = PULSE_IMAGE_FORMAT_R8G8B8A8_UNORM;
|
||||
image_create_info.usage = PULSE_IMAGE_USAGE_STORAGE_WRITE;
|
||||
image_create_info.width = 256;
|
||||
image_create_info.height = 256;
|
||||
image_create_info.layer_count_or_depth = 1;
|
||||
PulseImage image = PulseCreateImage(device, &image_create_info);
|
||||
TEST_ASSERT_NOT_EQUAL_MESSAGE(image, PULSE_NULL_HANDLE, PulseVerbaliseErrorType(PulseGetLastErrorType()));
|
||||
PulseDestroyImage(device, image);
|
||||
}
|
||||
{
|
||||
PulseImageCreateInfo image_create_info = { 0 };
|
||||
image_create_info.type = PULSE_IMAGE_TYPE_2D;
|
||||
image_create_info.format = PULSE_IMAGE_FORMAT_R8G8B8A8_UNORM;
|
||||
image_create_info.usage = PULSE_IMAGE_USAGE_STORAGE_SIMULTANEOUS_READWRITE;
|
||||
image_create_info.width = 256;
|
||||
image_create_info.height = 256;
|
||||
image_create_info.layer_count_or_depth = 1;
|
||||
PulseImage image = PulseCreateImage(device, &image_create_info);
|
||||
TEST_ASSERT_NOT_EQUAL_MESSAGE(image, PULSE_NULL_HANDLE, PulseVerbaliseErrorType(PulseGetLastErrorType()));
|
||||
PulseDestroyImage(device, image);
|
||||
}
|
||||
{
|
||||
PulseImageCreateInfo image_create_info = { 0 };
|
||||
image_create_info.type = PULSE_IMAGE_TYPE_2D;
|
||||
image_create_info.format = PULSE_IMAGE_FORMAT_R8_SNORM;
|
||||
image_create_info.usage = PULSE_IMAGE_USAGE_STORAGE_READ;
|
||||
image_create_info.width = 256;
|
||||
image_create_info.height = 256;
|
||||
image_create_info.layer_count_or_depth = 1;
|
||||
PulseImage image = PulseCreateImage(device, &image_create_info);
|
||||
TEST_ASSERT_NOT_EQUAL_MESSAGE(image, PULSE_NULL_HANDLE, PulseVerbaliseErrorType(PulseGetLastErrorType()));
|
||||
PulseDestroyImage(device, image);
|
||||
if(PulseIsImageFormatValid(device, format, type, usages))
|
||||
{
|
||||
PulseImage image = PulseCreateImage(device, &image_create_info);
|
||||
TEST_ASSERT_NOT_EQUAL_MESSAGE(image, PULSE_NULL_HANDLE, PulseVerbaliseErrorType(PulseGetLastErrorType()));
|
||||
PulseDestroyImage(device, image);
|
||||
}
|
||||
else
|
||||
{
|
||||
DISABLE_ERRORS;
|
||||
|
||||
PulseImage image = PulseCreateImage(device, &image_create_info);
|
||||
TEST_ASSERT_EQUAL(image, PULSE_NULL_HANDLE);
|
||||
PulseDestroyImage(device, image);
|
||||
|
||||
ENABLE_ERRORS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DISABLE_ERRORS;
|
||||
|
||||
Reference in New Issue
Block a user