mirror of
https://github.com/Kbz-8/Pulse.git
synced 2026-01-11 15:33:34 +00:00
yes CI skip
This commit is contained in:
@@ -213,14 +213,10 @@ PulseDevice OpenGLCreateDevice(PulseBackend backend, PulseDevice* forbiden_devic
|
|||||||
pulse_device->backend = backend;
|
pulse_device->backend = backend;
|
||||||
|
|
||||||
const char* core_extensions[] = {
|
const char* core_extensions[] = {
|
||||||
"GL_ARB_texture_rg",
|
|
||||||
"GL_EXT_texture_storage",
|
|
||||||
"GL_EXT_texture_snorm",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* es_extensions[] = {
|
const char* es_extensions[] = {
|
||||||
"GL_EXT_texture_rg",
|
"GL_EXT_texture_norm16",
|
||||||
"GL_EXT_texture_storage",
|
|
||||||
"GL_EXT_texture_snorm",
|
"GL_EXT_texture_snorm",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ static GLenum PulseImageFormatToGLInternalFormat[] = {
|
|||||||
GL_RGB10_A2, // R10G10B10A2_UNORM
|
GL_RGB10_A2, // R10G10B10A2_UNORM
|
||||||
GL_RGB565, // B5G6R5_UNORM
|
GL_RGB565, // B5G6R5_UNORM
|
||||||
GL_RGB5_A1, // B5G5R5A1_UNORM
|
GL_RGB5_A1, // B5G5R5A1_UNORM
|
||||||
GL_INVALID_ENUM, // B4G4R4A4_UNORM
|
GL_RGBA4, // B4G4R4A4_UNORM
|
||||||
GL_BGRA8_EXT, // B8G8R8A8_UNORM
|
GL_BGRA8_EXT, // B8G8R8A8_UNORM
|
||||||
GL_INVALID_ENUM, // BC1_UNORM
|
GL_INVALID_ENUM, // BC1_UNORM
|
||||||
GL_INVALID_ENUM, // BC2_UNORM
|
GL_INVALID_ENUM, // BC2_UNORM
|
||||||
@@ -64,9 +64,18 @@ static GLenum PulseImageFormatToGLInternalFormat[] = {
|
|||||||
GL_RG32I, // R32G32_INT
|
GL_RG32I, // R32G32_INT
|
||||||
GL_RGBA32I, // R32G32B32A32_INT
|
GL_RGBA32I, // R32G32B32A32_INT
|
||||||
};
|
};
|
||||||
PULSE_STATIC_ASSERT(PulseImageFormatToWGPUTextureFormat, (sizeof(PulseImageFormatToGLInternalFormat) / sizeof(GLenum)) == PULSE_IMAGE_FORMAT_MAX_ENUM);
|
PULSE_STATIC_ASSERT(PulseImageFormatToGLInternalFormat, PULSE_SIZEOF_ARRAY(PulseImageFormatToGLInternalFormat) == PULSE_IMAGE_FORMAT_MAX_ENUM);
|
||||||
|
|
||||||
PulseImage OpenGLCreateImage(PulseDevice device, const PulseImageCreateInfo* create_infos)
|
static GLenum PulseImageTypeToGLTextureType[] = {
|
||||||
|
GL_TEXTURE_2D, //PULSE_IMAGE_TYPE_2D
|
||||||
|
GL_TEXTURE_2D_ARRAY, //PULSE_IMAGE_TYPE_2D_ARRAY
|
||||||
|
GL_TEXTURE_3D, //PULSE_IMAGE_TYPE_3D
|
||||||
|
GL_TEXTURE_CUBE_MAP, //PULSE_IMAGE_TYPE_CUBE
|
||||||
|
GL_TEXTURE_CUBE_MAP_ARRAY, //PULSE_IMAGE_TYPE_CUBE_ARRAY
|
||||||
|
};
|
||||||
|
PULSE_STATIC_ASSERT(PulseImageTypeToGLTextureType, PULSE_SIZEOF_ARRAY(PulseImageTypeToGLTextureType) == PULSE_IMAGE_TYPE_MAX_ENUM);
|
||||||
|
|
||||||
|
PulseImage OpenGLCreateImageTryAndFail(PulseDevice device, const PulseImageCreateInfo* create_infos, bool try_and_fail)
|
||||||
{
|
{
|
||||||
OpenGLDevice* opengl_device = OPENGL_RETRIEVE_DRIVER_DATA_AS(device, OpenGLDevice*);
|
OpenGLDevice* opengl_device = OPENGL_RETRIEVE_DRIVER_DATA_AS(device, OpenGLDevice*);
|
||||||
|
|
||||||
@@ -76,12 +85,52 @@ PulseImage OpenGLCreateImage(PulseDevice device, const PulseImageCreateInfo* cre
|
|||||||
OpenGLImage* opengl_image = (OpenGLImage*)calloc(1, sizeof(OpenGLImage));
|
OpenGLImage* opengl_image = (OpenGLImage*)calloc(1, sizeof(OpenGLImage));
|
||||||
PULSE_CHECK_ALLOCATION_RETVAL(opengl_image, PULSE_NULL_HANDLE);
|
PULSE_CHECK_ALLOCATION_RETVAL(opengl_image, PULSE_NULL_HANDLE);
|
||||||
|
|
||||||
|
GLenum image_type = PulseImageTypeToGLTextureType[create_infos->type];
|
||||||
|
|
||||||
|
// TODO error message if image_type is invalid
|
||||||
|
|
||||||
|
opengl_device->glGenTextures(device, 1, &opengl_image->image);
|
||||||
|
opengl_device->glBindTexture(device, image_type, opengl_image->image);
|
||||||
|
if(try_and_fail)
|
||||||
|
{
|
||||||
|
while(((PFNGLGETERRORPROC)opengl_device->original_function_ptrs[glGetError])() != GL_NO_ERROR); // Clear errors
|
||||||
|
((PFNGLTEXSTORAGE2DPROC)opengl_device->original_function_ptrs[glTexStorage2D])();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(create_infos->type == PULSE_IMAGE_TYPE_3D)
|
||||||
|
opengl_device->glTexStorage3D(device, image_type, 1, PulseImageFormatToGLInternalFormat[create_infos->format], create_infos->width, create_infos->width, create_infos->layer_count_or_depth);
|
||||||
|
else
|
||||||
|
opengl_device->glTexStorage2D(device, image_type, 1, PulseImageFormatToGLInternalFormat[create_infos->format], create_infos->width, create_infos->height);
|
||||||
|
}
|
||||||
|
if(create_infos->format == PULSE_IMAGE_FORMAT_A8_UNORM)
|
||||||
|
{
|
||||||
|
opengl_device->glTexParameteri(device, image_type, GL_TEXTURE_SWIZZLE_R, GL_ZERO);
|
||||||
|
opengl_device->glTexParameteri(device, image_type, GL_TEXTURE_SWIZZLE_G, GL_ZERO);
|
||||||
|
opengl_device->glTexParameteri(device, image_type, GL_TEXTURE_SWIZZLE_B, GL_ZERO);
|
||||||
|
opengl_device->glTexParameteri(device, image_type, GL_TEXTURE_SWIZZLE_A, GL_RED);
|
||||||
|
}
|
||||||
|
else if(create_infos->format == PULSE_IMAGE_FORMAT_B4G4R4A4_UNORM)
|
||||||
|
{
|
||||||
|
opengl_device->glTexParameteri(device, image_type, GL_TEXTURE_SWIZZLE_R, GL_GREEN);
|
||||||
|
opengl_device->glTexParameteri(device, image_type, GL_TEXTURE_SWIZZLE_G, GL_RED);
|
||||||
|
opengl_device->glTexParameteri(device, image_type, GL_TEXTURE_SWIZZLE_B, GL_ALPHA);
|
||||||
|
opengl_device->glTexParameteri(device, image_type, GL_TEXTURE_SWIZZLE_A, GL_BLUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
opengl_device->glBindTexture(device, image_type, 0); // Unbind
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PulseImage OpenGLCreateImage(PulseDevice device, const PulseImageCreateInfo* create_infos)
|
||||||
|
{
|
||||||
|
return OpenGLCreateImageTryAndFail(device, create_infos, false);
|
||||||
|
}
|
||||||
|
|
||||||
bool OpenGLIsImageFormatValid(PulseDevice device, PulseImageFormat format, PulseImageType type, PulseImageUsageFlags usage)
|
bool OpenGLIsImageFormatValid(PulseDevice device, PulseImageFormat format, PulseImageType type, PulseImageUsageFlags usage)
|
||||||
{
|
{
|
||||||
|
OpenGLDevice* opengl_device = OPENGL_RETRIEVE_DRIVER_DATA_AS(device, OpenGLDevice*);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenGLCopyImageToBuffer(PulseCommandList cmd, const PulseImageRegion* src, const PulseBufferRegion* dst)
|
bool OpenGLCopyImageToBuffer(PulseCommandList cmd, const PulseImageRegion* src, const PulseBufferRegion* dst)
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ static WGPUTextureFormat PulseImageFormatToWGPUTextureFormat[] = {
|
|||||||
WGPUTextureFormat_RG32Sint, // R32G32_INT
|
WGPUTextureFormat_RG32Sint, // R32G32_INT
|
||||||
WGPUTextureFormat_RGBA32Sint, // R32G32B32A32_INT
|
WGPUTextureFormat_RGBA32Sint, // R32G32B32A32_INT
|
||||||
};
|
};
|
||||||
PULSE_STATIC_ASSERT(PulseImageFormatToWGPUTextureFormat, (sizeof(PulseImageFormatToWGPUTextureFormat) / sizeof(WGPUTextureFormat)) == PULSE_IMAGE_FORMAT_MAX_ENUM);
|
PULSE_STATIC_ASSERT(PulseImageFormatToWGPUTextureFormat, PULSE_SIZEOF_ARRAY(PulseImageFormatToWGPUTextureFormat) == PULSE_IMAGE_FORMAT_MAX_ENUM);
|
||||||
|
|
||||||
static WGPUTextureDimension PulseImageTypeToWGPUTextureDimension[] = {
|
static WGPUTextureDimension PulseImageTypeToWGPUTextureDimension[] = {
|
||||||
WGPUTextureDimension_2D, //PULSE_IMAGE_TYPE_2D
|
WGPUTextureDimension_2D, //PULSE_IMAGE_TYPE_2D
|
||||||
@@ -72,7 +72,7 @@ static WGPUTextureDimension PulseImageTypeToWGPUTextureDimension[] = {
|
|||||||
WGPUTextureDimension_2D, //PULSE_IMAGE_TYPE_CUBE
|
WGPUTextureDimension_2D, //PULSE_IMAGE_TYPE_CUBE
|
||||||
WGPUTextureDimension_2D, //PULSE_IMAGE_TYPE_CUBE_ARRAY
|
WGPUTextureDimension_2D, //PULSE_IMAGE_TYPE_CUBE_ARRAY
|
||||||
};
|
};
|
||||||
PULSE_STATIC_ASSERT(PulseImageTypeToWGPUTextureDimension, (sizeof(PulseImageTypeToWGPUTextureDimension) / sizeof(WGPUTextureDimension)) == PULSE_IMAGE_TYPE_MAX_ENUM);
|
PULSE_STATIC_ASSERT(PulseImageTypeToWGPUTextureDimension, PULSE_SIZEOF_ARRAY(PulseImageTypeToWGPUTextureDimension) == PULSE_IMAGE_TYPE_MAX_ENUM);
|
||||||
|
|
||||||
static WGPUTextureViewDimension PulseImageTypeToWGPUTextureViewDimension[] = {
|
static WGPUTextureViewDimension PulseImageTypeToWGPUTextureViewDimension[] = {
|
||||||
WGPUTextureViewDimension_2D, //PULSE_IMAGE_TYPE_2D
|
WGPUTextureViewDimension_2D, //PULSE_IMAGE_TYPE_2D
|
||||||
@@ -81,7 +81,7 @@ static WGPUTextureViewDimension PulseImageTypeToWGPUTextureViewDimension[] = {
|
|||||||
WGPUTextureViewDimension_Cube, //PULSE_IMAGE_TYPE_CUBE
|
WGPUTextureViewDimension_Cube, //PULSE_IMAGE_TYPE_CUBE
|
||||||
WGPUTextureViewDimension_CubeArray, //PULSE_IMAGE_TYPE_CUBE_ARRAY
|
WGPUTextureViewDimension_CubeArray, //PULSE_IMAGE_TYPE_CUBE_ARRAY
|
||||||
};
|
};
|
||||||
PULSE_STATIC_ASSERT(PulseImageTypeToWGPUTextureViewDimension, (sizeof(PulseImageTypeToWGPUTextureViewDimension) / sizeof(WGPUTextureViewDimension)) == PULSE_IMAGE_TYPE_MAX_ENUM);
|
PULSE_STATIC_ASSERT(PulseImageTypeToWGPUTextureViewDimension, PULSE_SIZEOF_ARRAY(PulseImageTypeToWGPUTextureViewDimension) == PULSE_IMAGE_TYPE_MAX_ENUM);
|
||||||
|
|
||||||
PulseImage WebGPUCreateImage(PulseDevice device, const PulseImageCreateInfo* create_infos)
|
PulseImage WebGPUCreateImage(PulseDevice device, const PulseImageCreateInfo* create_infos)
|
||||||
{
|
{
|
||||||
|
|||||||
1
Tests/Shaders/.gitignore
vendored
1
Tests/Shaders/.gitignore
vendored
@@ -2,3 +2,4 @@
|
|||||||
*.wgsl.h
|
*.wgsl.h
|
||||||
*.json
|
*.json
|
||||||
*.glsl.h
|
*.glsl.h
|
||||||
|
*.glsl
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
#version 310 es
|
|
||||||
|
|
||||||
// compute shader - this file was generated by NZSL compiler (Nazara Shading Language)
|
|
||||||
|
|
||||||
precision highp int;
|
|
||||||
#if GL_FRAGMENT_PRECISION_HIGH
|
|
||||||
precision highp float;
|
|
||||||
#else
|
|
||||||
precision mediump float;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
|
||||||
|
|
||||||
// header end
|
|
||||||
|
|
||||||
struct Input
|
|
||||||
{
|
|
||||||
uvec3 indices;
|
|
||||||
};
|
|
||||||
|
|
||||||
// struct SSBO omitted (used as UBO/SSBO)
|
|
||||||
|
|
||||||
layout(binding = 0, std430) readonly buffer _nzslBindingread_ssbo
|
|
||||||
{
|
|
||||||
uint data[];
|
|
||||||
} read_ssbo;
|
|
||||||
|
|
||||||
layout(binding = 1, std430) writeonly buffer _nzslBindingwrite_ssbo
|
|
||||||
{
|
|
||||||
uint data[];
|
|
||||||
} write_ssbo;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
Input input_;
|
|
||||||
input_.indices = gl_GlobalInvocationID;
|
|
||||||
|
|
||||||
write_ssbo.data[input_.indices.x * input_.indices.y] = read_ssbo.data[input_.indices.x * input_.indices.y];
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
#version 310 es
|
|
||||||
|
|
||||||
// compute shader - this file was generated by NZSL compiler (Nazara Shading Language)
|
|
||||||
|
|
||||||
precision highp int;
|
|
||||||
#if GL_FRAGMENT_PRECISION_HIGH
|
|
||||||
precision highp float;
|
|
||||||
precision highp image2D;
|
|
||||||
#else
|
|
||||||
precision mediump float;
|
|
||||||
precision mediump image2D;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
|
||||||
|
|
||||||
// header end
|
|
||||||
|
|
||||||
struct Input
|
|
||||||
{
|
|
||||||
uvec3 indices;
|
|
||||||
};
|
|
||||||
|
|
||||||
// struct SSBO omitted (used as UBO/SSBO)
|
|
||||||
|
|
||||||
layout(binding = 0, rgba8) uniform readonly image2D read_texture;
|
|
||||||
layout(binding = 1, std430) readonly buffer _nzslBindingread_ssbo
|
|
||||||
{
|
|
||||||
uint data[];
|
|
||||||
} read_ssbo;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
Input input_;
|
|
||||||
input_.indices = gl_GlobalInvocationID;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
#version 310 es
|
|
||||||
|
|
||||||
// compute shader - this file was generated by NZSL compiler (Nazara Shading Language)
|
|
||||||
|
|
||||||
precision highp int;
|
|
||||||
#if GL_FRAGMENT_PRECISION_HIGH
|
|
||||||
precision highp float;
|
|
||||||
precision highp image2D;
|
|
||||||
#else
|
|
||||||
precision mediump float;
|
|
||||||
precision mediump image2D;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
|
||||||
|
|
||||||
// header end
|
|
||||||
|
|
||||||
struct Input
|
|
||||||
{
|
|
||||||
uvec3 indices;
|
|
||||||
};
|
|
||||||
|
|
||||||
// struct SSBO omitted (used as UBO/SSBO)
|
|
||||||
|
|
||||||
layout(binding = 0, rgba8) uniform readonly image2D read_texture;
|
|
||||||
layout(binding = 1, std430) readonly buffer _nzslBindingread_ssbo
|
|
||||||
{
|
|
||||||
uint data[];
|
|
||||||
} read_ssbo;
|
|
||||||
|
|
||||||
layout(binding = 2) uniform image2D write_texture;
|
|
||||||
layout(binding = 3, std430) writeonly buffer _nzslBindingwrite_ssbo
|
|
||||||
{
|
|
||||||
uint data[];
|
|
||||||
} write_ssbo;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
Input input_;
|
|
||||||
input_.indices = gl_GlobalInvocationID;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
#version 310 es
|
|
||||||
|
|
||||||
// compute shader - this file was generated by NZSL compiler (Nazara Shading Language)
|
|
||||||
|
|
||||||
precision highp int;
|
|
||||||
#if GL_FRAGMENT_PRECISION_HIGH
|
|
||||||
precision highp float;
|
|
||||||
#else
|
|
||||||
precision mediump float;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
layout(local_size_x = 32, local_size_y = 32, local_size_z = 1) in;
|
|
||||||
|
|
||||||
// header end
|
|
||||||
|
|
||||||
struct Input
|
|
||||||
{
|
|
||||||
uvec3 indices;
|
|
||||||
};
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
Input input_;
|
|
||||||
input_.indices = gl_GlobalInvocationID;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
#version 310 es
|
|
||||||
|
|
||||||
// compute shader - this file was generated by NZSL compiler (Nazara Shading Language)
|
|
||||||
|
|
||||||
precision highp int;
|
|
||||||
#if GL_FRAGMENT_PRECISION_HIGH
|
|
||||||
precision highp float;
|
|
||||||
#else
|
|
||||||
precision mediump float;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
|
||||||
|
|
||||||
// header end
|
|
||||||
|
|
||||||
struct Input
|
|
||||||
{
|
|
||||||
uvec3 indices;
|
|
||||||
};
|
|
||||||
|
|
||||||
// struct SSBO omitted (used as UBO/SSBO)
|
|
||||||
|
|
||||||
layout(binding = 0, std430) buffer _nzslBindingssbo
|
|
||||||
{
|
|
||||||
uint data[];
|
|
||||||
} ssbo;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
Input input_;
|
|
||||||
input_.indices = gl_GlobalInvocationID;
|
|
||||||
|
|
||||||
ssbo.data[input_.indices.x * input_.indices.y] = uint(-1);
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
#version 310 es
|
|
||||||
|
|
||||||
// compute shader - this file was generated by NZSL compiler (Nazara Shading Language)
|
|
||||||
|
|
||||||
precision highp int;
|
|
||||||
#if GL_FRAGMENT_PRECISION_HIGH
|
|
||||||
precision highp float;
|
|
||||||
precision highp image2D;
|
|
||||||
#else
|
|
||||||
precision mediump float;
|
|
||||||
precision mediump image2D;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
|
||||||
|
|
||||||
// header end
|
|
||||||
|
|
||||||
struct Input
|
|
||||||
{
|
|
||||||
uvec3 indices;
|
|
||||||
};
|
|
||||||
|
|
||||||
// struct SSBO omitted (used as UBO/SSBO)
|
|
||||||
|
|
||||||
layout(binding = 0, rgba8) uniform image2D write_texture;
|
|
||||||
layout(binding = 1, std430) buffer _nzslBindingwrite_ssbo
|
|
||||||
{
|
|
||||||
uint data[];
|
|
||||||
} write_ssbo;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
Input input_;
|
|
||||||
input_.indices = gl_GlobalInvocationID;
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user