mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 21:58:31 +09:00
[Fix] (MG_Impl, MG_State, MG_Backend, MG_Util): Do source audit by Codex.
This commit is contained in:
@@ -48,11 +48,14 @@ namespace MobileGL::MG_Util::BackendLoader {
|
||||
return false;
|
||||
}
|
||||
|
||||
Bool allRequiredLoaded = true;
|
||||
|
||||
#define INIT_GLES_FUNC(name) \
|
||||
do { \
|
||||
funcs.name = (MG_External::GLES::name##_PTR)procAddress(#name); \
|
||||
if (!funcs.name) { \
|
||||
MGLOG_E("Failed to load GLES function: %s", #name); \
|
||||
allRequiredLoaded = false; \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
@@ -149,6 +152,8 @@ namespace MobileGL::MG_Util::BackendLoader {
|
||||
INIT_GLES_FUNC(glIsTexture)
|
||||
INIT_GLES_FUNC(glLineWidth)
|
||||
INIT_GLES_FUNC(glLinkProgram)
|
||||
INIT_GLES_FUNC(glLogicOp)
|
||||
INIT_GLES_FUNC(glPointSize)
|
||||
INIT_GLES_FUNC(glPixelStorei)
|
||||
INIT_GLES_FUNC(glPolygonOffset)
|
||||
INIT_GLES_FUNC(glReadPixels)
|
||||
@@ -428,7 +433,7 @@ namespace MobileGL::MG_Util::BackendLoader {
|
||||
INIT_GLES_FUNC(glMultiDrawElementsIndirectEXT)
|
||||
INIT_GLES_FUNC(glMultiDrawElementsBaseVertexEXT)
|
||||
}
|
||||
return true;
|
||||
return allRequiredLoaded;
|
||||
}
|
||||
|
||||
Bool AcquireEGLFunctions(MG_External::EGLFunctionsTable& funcs) {
|
||||
@@ -438,11 +443,15 @@ namespace MobileGL::MG_Util::BackendLoader {
|
||||
MGLOG_E("Failed to open libEGL.so");
|
||||
return false;
|
||||
}
|
||||
|
||||
Bool allRequiredLoaded = true;
|
||||
|
||||
#define INIT_EGL_FUNC(name) \
|
||||
do { \
|
||||
funcs.name = (MG_External::EGL::name##_PTR)ProcAddress(eglLib, #name); \
|
||||
if (!funcs.name) { \
|
||||
MGLOG_E("Failed to load EGL function: %s", #name); \
|
||||
allRequiredLoaded = false; \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
@@ -495,7 +504,7 @@ namespace MobileGL::MG_Util::BackendLoader {
|
||||
INIT_EGL_FUNC(eglGetPlatformDisplay)
|
||||
INIT_EGL_FUNC(eglWaitSync)
|
||||
}
|
||||
return true;
|
||||
return allRequiredLoaded;
|
||||
}
|
||||
|
||||
Bool FillInGLESCapabilities(MG_External::GLESCapabilities& caps, const MG_External::GLESFunctionsTable& glesFuncs) {
|
||||
@@ -535,6 +544,179 @@ namespace MobileGL::MG_Util::BackendLoader {
|
||||
MGLOG_I("OpenGL ES capabilities:");
|
||||
glesFuncs.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &caps.UniformBufferOffsetAlignment);
|
||||
MGLOG_I(" GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: %d", caps.UniformBufferOffsetAlignment);
|
||||
GLfloat aliasedLineWidthRange[2] = {1.0f, 1.0f};
|
||||
GLfloat smoothLineWidthRange[2] = {1.0f, 1.0f};
|
||||
GLfloat smoothLineWidthGranularity = 1.0f;
|
||||
GLfloat aliasedPointSizeRange[2] = {1.0f, 1.0f};
|
||||
GLfloat viewportBoundsRange[2] = {0.0f, 0.0f};
|
||||
GLint maxViewportDims[2] = {16384, 16384};
|
||||
GLint viewportSubpixelBits = 0;
|
||||
GLint max3DTextureSize = 16384;
|
||||
GLint maxArrayTextureLayers = 2048;
|
||||
GLint maxCubeMapTextureSize = 16384;
|
||||
GLint maxFramebufferWidth = 16384;
|
||||
GLint maxFramebufferHeight = 16384;
|
||||
GLint maxFramebufferLayers = 2048;
|
||||
GLint maxRenderbufferSize = 16384;
|
||||
GLint maxTextureSize = 16384;
|
||||
GLint maxColorTextureSamples = 1;
|
||||
GLint maxDepthTextureSamples = 1;
|
||||
GLint maxFramebufferSamples = 1;
|
||||
GLint maxIntegerSamples = 1;
|
||||
GLint maxSamples = 1;
|
||||
GLint maxSampleMaskWords = 1;
|
||||
GLint maxTextureImageUnits = 32;
|
||||
GLint maxVertexTextureImageUnits = 32;
|
||||
GLint maxComputeTextureImageUnits = 32;
|
||||
GLint maxCombinedTextureImageUnits = 192;
|
||||
GLint maxVertexAttribs = 16;
|
||||
GLint maxComputeShaderStorageBlocks = 8;
|
||||
GLint maxCombinedShaderStorageBlocks = 32;
|
||||
GLint maxComputeUniformBlocks = 12;
|
||||
GLint maxComputeWorkGroupInvocations = 128;
|
||||
GLint maxShaderStorageBufferBindings = 8;
|
||||
GLint maxTextureBufferSize = 65536;
|
||||
GLint maxUniformBufferBindings = 24;
|
||||
GLint maxUniformBlockSize = 16384;
|
||||
GLint maxImageUnits = 8;
|
||||
GLint maxCombinedImageUniforms = 8;
|
||||
GLint maxComputeImageUniforms = 8;
|
||||
GLint maxDrawBuffers = 8;
|
||||
GLint maxColorAttachments = 8;
|
||||
GLint maxClipDistances = 8;
|
||||
GLint maxViewports = 16;
|
||||
glesFuncs.glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, aliasedLineWidthRange);
|
||||
glesFuncs.glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, smoothLineWidthRange);
|
||||
glesFuncs.glGetFloatv(GL_SMOOTH_LINE_WIDTH_GRANULARITY, &smoothLineWidthGranularity);
|
||||
glesFuncs.glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, aliasedPointSizeRange);
|
||||
glesFuncs.glGetFloatv(GL_VIEWPORT_BOUNDS_RANGE, viewportBoundsRange);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &max3DTextureSize);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &maxArrayTextureLayers);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &maxCubeMapTextureSize);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_FRAMEBUFFER_WIDTH, &maxFramebufferWidth);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_FRAMEBUFFER_HEIGHT, &maxFramebufferHeight);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_FRAMEBUFFER_LAYERS, &maxFramebufferLayers);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &maxRenderbufferSize);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &maxColorTextureSamples);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_DEPTH_TEXTURE_SAMPLES, &maxDepthTextureSamples);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_FRAMEBUFFER_SAMPLES, &maxFramebufferSamples);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &maxIntegerSamples);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_SAMPLES, &maxSamples);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &maxSampleMaskWords);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureImageUnits);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &maxVertexTextureImageUnits);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS, &maxComputeTextureImageUnits);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxCombinedTextureImageUnits);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS, &maxComputeShaderStorageBlocks);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS, &maxCombinedShaderStorageBlocks);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_COMPUTE_UNIFORM_BLOCKS, &maxComputeUniformBlocks);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS, &maxComputeWorkGroupInvocations);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS, &maxShaderStorageBufferBindings);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &maxTextureBufferSize);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &maxUniformBlockSize);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_IMAGE_UNITS, &maxImageUnits);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_COMBINED_IMAGE_UNIFORMS, &maxCombinedImageUniforms);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_COMPUTE_IMAGE_UNIFORMS, &maxComputeImageUniforms);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_CLIP_DISTANCES, &maxClipDistances);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_VIEWPORTS, &maxViewports);
|
||||
glesFuncs.glGetIntegerv(GL_MAX_VIEWPORT_DIMS, maxViewportDims);
|
||||
glesFuncs.glGetIntegerv(GL_VIEWPORT_SUBPIXEL_BITS, &viewportSubpixelBits);
|
||||
caps.AliasedLineWidthRangeMin = aliasedLineWidthRange[0];
|
||||
caps.AliasedLineWidthRangeMax = aliasedLineWidthRange[1];
|
||||
caps.SmoothLineWidthRangeMin = smoothLineWidthRange[0];
|
||||
caps.SmoothLineWidthRangeMax = smoothLineWidthRange[1];
|
||||
caps.SmoothLineWidthGranularity = smoothLineWidthGranularity;
|
||||
caps.PointSizeRangeMin = aliasedPointSizeRange[0];
|
||||
caps.PointSizeRangeMax = aliasedPointSizeRange[1];
|
||||
caps.PointSizeGranularity = 1.0f;
|
||||
caps.Max3DTextureSize = max3DTextureSize;
|
||||
caps.MaxArrayTextureLayers = maxArrayTextureLayers;
|
||||
caps.MaxCubeMapTextureSize = maxCubeMapTextureSize;
|
||||
caps.MaxFramebufferWidth = maxFramebufferWidth;
|
||||
caps.MaxFramebufferHeight = maxFramebufferHeight;
|
||||
caps.MaxFramebufferLayers = maxFramebufferLayers;
|
||||
caps.MaxRenderbufferSize = maxRenderbufferSize;
|
||||
caps.MaxTextureSize = maxTextureSize;
|
||||
caps.MaxColorTextureSamples = maxColorTextureSamples;
|
||||
caps.MaxDepthTextureSamples = maxDepthTextureSamples;
|
||||
caps.MaxFramebufferSamples = maxFramebufferSamples;
|
||||
caps.MaxIntegerSamples = maxIntegerSamples;
|
||||
caps.MaxSamples = maxSamples;
|
||||
caps.MaxSampleMaskWords = maxSampleMaskWords;
|
||||
caps.MaxTextureImageUnits = maxTextureImageUnits;
|
||||
caps.MaxVertexTextureImageUnits = maxVertexTextureImageUnits;
|
||||
caps.MaxComputeTextureImageUnits = maxComputeTextureImageUnits;
|
||||
caps.MaxCombinedTextureImageUnits = maxCombinedTextureImageUnits;
|
||||
caps.MaxVertexAttribs = maxVertexAttribs;
|
||||
caps.MaxComputeShaderStorageBlocks = maxComputeShaderStorageBlocks;
|
||||
caps.MaxCombinedShaderStorageBlocks = maxCombinedShaderStorageBlocks;
|
||||
caps.MaxComputeUniformBlocks = maxComputeUniformBlocks;
|
||||
caps.MaxComputeWorkGroupInvocations = maxComputeWorkGroupInvocations;
|
||||
caps.MaxShaderStorageBufferBindings = maxShaderStorageBufferBindings;
|
||||
caps.MaxTextureBufferSize = maxTextureBufferSize;
|
||||
caps.MaxUniformBufferBindings = maxUniformBufferBindings;
|
||||
caps.MaxUniformBlockSize = maxUniformBlockSize;
|
||||
caps.MaxImageUnits = maxImageUnits;
|
||||
caps.MaxCombinedImageUniforms = maxCombinedImageUniforms;
|
||||
caps.MaxComputeImageUniforms = maxComputeImageUniforms;
|
||||
caps.MaxDrawBuffers = maxDrawBuffers;
|
||||
caps.MaxColorAttachments = maxColorAttachments;
|
||||
caps.MaxClipDistances = maxClipDistances;
|
||||
caps.MaxViewports = maxViewports;
|
||||
caps.MaxViewportWidth = maxViewportDims[0];
|
||||
caps.MaxViewportHeight = maxViewportDims[1];
|
||||
caps.ViewportBoundsRangeMin = viewportBoundsRange[0];
|
||||
caps.ViewportBoundsRangeMax = viewportBoundsRange[1];
|
||||
caps.ViewportSubpixelBits = viewportSubpixelBits;
|
||||
MGLOG_I(" GL_ALIASED_LINE_WIDTH_RANGE: [%.3f, %.3f]", caps.AliasedLineWidthRangeMin,
|
||||
caps.AliasedLineWidthRangeMax);
|
||||
MGLOG_I(" GL_SMOOTH_LINE_WIDTH_RANGE: [%.3f, %.3f]", caps.SmoothLineWidthRangeMin,
|
||||
caps.SmoothLineWidthRangeMax);
|
||||
MGLOG_I(" GL_SMOOTH_LINE_WIDTH_GRANULARITY: %.3f", caps.SmoothLineWidthGranularity);
|
||||
MGLOG_I(" GL_ALIASED_POINT_SIZE_RANGE: [%.3f, %.3f]", caps.PointSizeRangeMin, caps.PointSizeRangeMax);
|
||||
MGLOG_I(" GL_MAX_3D_TEXTURE_SIZE: %d", caps.Max3DTextureSize);
|
||||
MGLOG_I(" GL_MAX_ARRAY_TEXTURE_LAYERS: %d", caps.MaxArrayTextureLayers);
|
||||
MGLOG_I(" GL_MAX_CUBE_MAP_TEXTURE_SIZE: %d", caps.MaxCubeMapTextureSize);
|
||||
MGLOG_I(" GL_MAX_FRAMEBUFFER_WIDTH: %d", caps.MaxFramebufferWidth);
|
||||
MGLOG_I(" GL_MAX_FRAMEBUFFER_HEIGHT: %d", caps.MaxFramebufferHeight);
|
||||
MGLOG_I(" GL_MAX_FRAMEBUFFER_LAYERS: %d", caps.MaxFramebufferLayers);
|
||||
MGLOG_I(" GL_MAX_RENDERBUFFER_SIZE: %d", caps.MaxRenderbufferSize);
|
||||
MGLOG_I(" GL_MAX_TEXTURE_SIZE: %d", caps.MaxTextureSize);
|
||||
MGLOG_I(" GL_MAX_COLOR_TEXTURE_SAMPLES: %d", caps.MaxColorTextureSamples);
|
||||
MGLOG_I(" GL_MAX_DEPTH_TEXTURE_SAMPLES: %d", caps.MaxDepthTextureSamples);
|
||||
MGLOG_I(" GL_MAX_FRAMEBUFFER_SAMPLES: %d", caps.MaxFramebufferSamples);
|
||||
MGLOG_I(" GL_MAX_INTEGER_SAMPLES: %d", caps.MaxIntegerSamples);
|
||||
MGLOG_I(" GL_MAX_SAMPLES: %d", caps.MaxSamples);
|
||||
MGLOG_I(" GL_MAX_SAMPLE_MASK_WORDS: %d", caps.MaxSampleMaskWords);
|
||||
MGLOG_I(" GL_MAX_TEXTURE_IMAGE_UNITS: %d", caps.MaxTextureImageUnits);
|
||||
MGLOG_I(" GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: %d", caps.MaxVertexTextureImageUnits);
|
||||
MGLOG_I(" GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS: %d", caps.MaxComputeTextureImageUnits);
|
||||
MGLOG_I(" GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: %d", caps.MaxCombinedTextureImageUnits);
|
||||
MGLOG_I(" GL_MAX_VERTEX_ATTRIBS: %d", caps.MaxVertexAttribs);
|
||||
MGLOG_I(" GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS: %d", caps.MaxComputeShaderStorageBlocks);
|
||||
MGLOG_I(" GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS: %d", caps.MaxCombinedShaderStorageBlocks);
|
||||
MGLOG_I(" GL_MAX_COMPUTE_UNIFORM_BLOCKS: %d", caps.MaxComputeUniformBlocks);
|
||||
MGLOG_I(" GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS: %d", caps.MaxComputeWorkGroupInvocations);
|
||||
MGLOG_I(" GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS: %d", caps.MaxShaderStorageBufferBindings);
|
||||
MGLOG_I(" GL_MAX_TEXTURE_BUFFER_SIZE: %d", caps.MaxTextureBufferSize);
|
||||
MGLOG_I(" GL_MAX_UNIFORM_BUFFER_BINDINGS: %d", caps.MaxUniformBufferBindings);
|
||||
MGLOG_I(" GL_MAX_UNIFORM_BLOCK_SIZE: %d", caps.MaxUniformBlockSize);
|
||||
MGLOG_I(" GL_MAX_IMAGE_UNITS: %d", caps.MaxImageUnits);
|
||||
MGLOG_I(" GL_MAX_COMBINED_IMAGE_UNIFORMS: %d", caps.MaxCombinedImageUniforms);
|
||||
MGLOG_I(" GL_MAX_COMPUTE_IMAGE_UNIFORMS: %d", caps.MaxComputeImageUniforms);
|
||||
MGLOG_I(" GL_MAX_DRAW_BUFFERS: %d", caps.MaxDrawBuffers);
|
||||
MGLOG_I(" GL_MAX_COLOR_ATTACHMENTS: %d", caps.MaxColorAttachments);
|
||||
MGLOG_I(" GL_MAX_CLIP_DISTANCES: %d", caps.MaxClipDistances);
|
||||
MGLOG_I(" GL_MAX_VIEWPORTS: %d", caps.MaxViewports);
|
||||
MGLOG_I(" GL_MAX_VIEWPORT_DIMS: [%d, %d]", caps.MaxViewportWidth, caps.MaxViewportHeight);
|
||||
MGLOG_I(" GL_VIEWPORT_BOUNDS_RANGE: [%.3f, %.3f]", caps.ViewportBoundsRangeMin,
|
||||
caps.ViewportBoundsRangeMax);
|
||||
MGLOG_I(" GL_VIEWPORT_SUBPIXEL_BITS: %d", caps.ViewportSubpixelBits);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -238,6 +238,8 @@ namespace MobileGL {
|
||||
GL_FUNC_TYPEDEF(GLboolean, glIsTexture, GLuint texture)
|
||||
GL_FUNC_TYPEDEF(void, glLineWidth, GLfloat width)
|
||||
GL_FUNC_TYPEDEF(void, glLinkProgram, GLuint program)
|
||||
GL_FUNC_TYPEDEF(void, glLogicOp, GLenum opcode)
|
||||
GL_FUNC_TYPEDEF(void, glPointSize, GLfloat size)
|
||||
GL_FUNC_TYPEDEF(void, glPixelStorei, GLenum pname, GLint param)
|
||||
GL_FUNC_TYPEDEF(void, glPolygonOffset, GLfloat factor, GLfloat units)
|
||||
GL_FUNC_TYPEDEF(void, glReadPixels, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
|
||||
@@ -725,6 +727,8 @@ namespace MobileGL {
|
||||
GL_FUNC_DECL(glIsTexture)
|
||||
GL_FUNC_DECL(glLineWidth)
|
||||
GL_FUNC_DECL(glLinkProgram)
|
||||
GL_FUNC_DECL(glLogicOp)
|
||||
GL_FUNC_DECL(glPointSize)
|
||||
GL_FUNC_DECL(glPixelStorei)
|
||||
GL_FUNC_DECL(glPolygonOffset)
|
||||
GL_FUNC_DECL(glReadPixels)
|
||||
@@ -1015,6 +1019,53 @@ namespace MobileGL {
|
||||
Bool SupportsPersistentMapping = false;
|
||||
Bool SupportsNorm16Texture = false;
|
||||
Int UniformBufferOffsetAlignment = 256;
|
||||
Float AliasedLineWidthRangeMin = 1.0f;
|
||||
Float AliasedLineWidthRangeMax = 1.0f;
|
||||
Float SmoothLineWidthRangeMin = 1.0f;
|
||||
Float SmoothLineWidthRangeMax = 1.0f;
|
||||
Float SmoothLineWidthGranularity = 1.0f;
|
||||
Float PointSizeRangeMin = 1.0f;
|
||||
Float PointSizeRangeMax = 1.0f;
|
||||
Float PointSizeGranularity = 1.0f;
|
||||
Int Max3DTextureSize = 16384;
|
||||
Int MaxArrayTextureLayers = 2048;
|
||||
Int MaxCubeMapTextureSize = 16384;
|
||||
Int MaxFramebufferWidth = 16384;
|
||||
Int MaxFramebufferHeight = 16384;
|
||||
Int MaxFramebufferLayers = 2048;
|
||||
Int MaxRenderbufferSize = 16384;
|
||||
Int MaxTextureSize = 16384;
|
||||
Int MaxColorTextureSamples = 1;
|
||||
Int MaxDepthTextureSamples = 1;
|
||||
Int MaxFramebufferSamples = 1;
|
||||
Int MaxIntegerSamples = 1;
|
||||
Int MaxSamples = 1;
|
||||
Int MaxSampleMaskWords = 1;
|
||||
Int MaxTextureImageUnits = 32;
|
||||
Int MaxVertexTextureImageUnits = 32;
|
||||
Int MaxComputeTextureImageUnits = 32;
|
||||
Int MaxCombinedTextureImageUnits = 192;
|
||||
Int MaxVertexAttribs = 16;
|
||||
Int MaxComputeShaderStorageBlocks = 8;
|
||||
Int MaxCombinedShaderStorageBlocks = 32;
|
||||
Int MaxComputeUniformBlocks = 12;
|
||||
Int MaxComputeWorkGroupInvocations = 128;
|
||||
Int MaxShaderStorageBufferBindings = 8;
|
||||
Int MaxTextureBufferSize = 65536;
|
||||
Int MaxUniformBufferBindings = 24;
|
||||
Int MaxUniformBlockSize = 16384;
|
||||
Int MaxImageUnits = 8;
|
||||
Int MaxCombinedImageUniforms = 8;
|
||||
Int MaxComputeImageUniforms = 8;
|
||||
Int MaxDrawBuffers = 8;
|
||||
Int MaxColorAttachments = 8;
|
||||
Int MaxClipDistances = 8;
|
||||
Int MaxViewports = 16;
|
||||
Int MaxViewportWidth = 16384;
|
||||
Int MaxViewportHeight = 16384;
|
||||
Float ViewportBoundsRangeMin = 0.0f;
|
||||
Float ViewportBoundsRangeMax = 0.0f;
|
||||
Int ViewportSubpixelBits = 0;
|
||||
};
|
||||
} // namespace MG_External
|
||||
|
||||
|
||||
@@ -15,6 +15,29 @@ namespace MobileGL::MG_Util::BackendLoader {
|
||||
PFN_vkGetPhysicalDeviceProperties2 vkGetPhysicalDeviceProperties2 = nullptr;
|
||||
};
|
||||
|
||||
Int ResolveMaxRenderbufferSize(const VkPhysicalDeviceLimits& limits) {
|
||||
return std::min<Int>(static_cast<Int>(limits.maxImageDimension2D),
|
||||
std::min<Int>(static_cast<Int>(limits.maxFramebufferWidth),
|
||||
static_cast<Int>(limits.maxFramebufferHeight)));
|
||||
}
|
||||
|
||||
Int MaxSampleCountFromFlags(VkSampleCountFlags flags) {
|
||||
if (flags & VK_SAMPLE_COUNT_64_BIT) return 64;
|
||||
if (flags & VK_SAMPLE_COUNT_32_BIT) return 32;
|
||||
if (flags & VK_SAMPLE_COUNT_16_BIT) return 16;
|
||||
if (flags & VK_SAMPLE_COUNT_8_BIT) return 8;
|
||||
if (flags & VK_SAMPLE_COUNT_4_BIT) return 4;
|
||||
if (flags & VK_SAMPLE_COUNT_2_BIT) return 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Int ResolveConservativeFramebufferSampleLimit(const VkPhysicalDeviceLimits& limits) {
|
||||
const VkSampleCountFlags commonFlags = limits.framebufferColorSampleCounts &
|
||||
limits.framebufferDepthSampleCounts &
|
||||
limits.framebufferStencilSampleCounts;
|
||||
return MaxSampleCountFromFlags(commonFlags);
|
||||
}
|
||||
|
||||
VulkanDynamicFunctions LoadVulkanDynamicFunctions(VkInstance instance) {
|
||||
VulkanDynamicFunctions loaded{};
|
||||
if (instance == VK_NULL_HANDLE) {
|
||||
@@ -83,6 +106,57 @@ namespace MobileGL::MG_Util::BackendLoader {
|
||||
caps.DeviceName = p.deviceName;
|
||||
caps.DriverVersionString = DecodeDriverVersion(p.driverVersion);
|
||||
caps.UniformBufferOffsetAlignment = static_cast<int>(p.limits.minUniformBufferOffsetAlignment);
|
||||
caps.AliasedLineWidthRangeMin = p.limits.lineWidthRange[0];
|
||||
caps.AliasedLineWidthRangeMax = p.limits.lineWidthRange[1];
|
||||
caps.SmoothLineWidthRangeMin = p.limits.lineWidthRange[0];
|
||||
caps.SmoothLineWidthRangeMax = p.limits.lineWidthRange[1];
|
||||
caps.SmoothLineWidthGranularity = p.limits.lineWidthGranularity;
|
||||
caps.PointSizeRangeMin = p.limits.pointSizeRange[0];
|
||||
caps.PointSizeRangeMax = p.limits.pointSizeRange[1];
|
||||
caps.PointSizeGranularity = p.limits.pointSizeGranularity;
|
||||
caps.Max3DTextureSize = static_cast<Int>(p.limits.maxImageDimension3D);
|
||||
caps.MaxArrayTextureLayers = static_cast<Int>(p.limits.maxImageArrayLayers);
|
||||
caps.MaxCubeMapTextureSize = static_cast<Int>(p.limits.maxImageDimensionCube);
|
||||
caps.MaxFramebufferWidth = static_cast<Int>(p.limits.maxFramebufferWidth);
|
||||
caps.MaxFramebufferHeight = static_cast<Int>(p.limits.maxFramebufferHeight);
|
||||
caps.MaxFramebufferLayers = static_cast<Int>(p.limits.maxFramebufferLayers);
|
||||
caps.MaxRenderbufferSize = ResolveMaxRenderbufferSize(p.limits);
|
||||
caps.MaxTextureSize = static_cast<Int>(p.limits.maxImageDimension2D);
|
||||
caps.MaxColorTextureSamples = MaxSampleCountFromFlags(p.limits.sampledImageColorSampleCounts);
|
||||
caps.MaxDepthTextureSamples = MaxSampleCountFromFlags(p.limits.sampledImageDepthSampleCounts);
|
||||
caps.MaxFramebufferSamples = ResolveConservativeFramebufferSampleLimit(p.limits);
|
||||
caps.MaxIntegerSamples = MaxSampleCountFromFlags(p.limits.sampledImageIntegerSampleCounts);
|
||||
caps.MaxSamples = caps.MaxFramebufferSamples;
|
||||
caps.MaxSampleMaskWords = static_cast<Int>(p.limits.maxSampleMaskWords);
|
||||
caps.MaxTextureImageUnits = static_cast<Int>(p.limits.maxPerStageDescriptorSampledImages);
|
||||
caps.MaxVertexTextureImageUnits = static_cast<Int>(p.limits.maxPerStageDescriptorSampledImages);
|
||||
caps.MaxComputeTextureImageUnits = static_cast<Int>(p.limits.maxPerStageDescriptorSampledImages);
|
||||
caps.MaxCombinedTextureImageUnits = static_cast<Int>(p.limits.maxDescriptorSetSampledImages);
|
||||
caps.MaxVertexAttribs = static_cast<Int>(p.limits.maxVertexInputAttributes);
|
||||
caps.MaxComputeShaderStorageBlocks = static_cast<Int>(p.limits.maxPerStageDescriptorStorageBuffers);
|
||||
caps.MaxCombinedShaderStorageBlocks = static_cast<Int>(p.limits.maxDescriptorSetStorageBuffers);
|
||||
caps.MaxComputeUniformBlocks = static_cast<Int>(p.limits.maxPerStageDescriptorUniformBuffers);
|
||||
caps.MaxComputeWorkGroupInvocations = static_cast<Int>(p.limits.maxComputeWorkGroupInvocations);
|
||||
caps.MaxShaderStorageBufferBindings = static_cast<Int>(p.limits.maxDescriptorSetStorageBuffers);
|
||||
caps.MaxTextureBufferSize = static_cast<Int>(p.limits.maxTexelBufferElements);
|
||||
caps.MaxUniformBufferBindings = static_cast<Int>(p.limits.maxDescriptorSetUniformBuffers);
|
||||
caps.MaxUniformBlockSize = static_cast<Int>(p.limits.maxUniformBufferRange);
|
||||
caps.MaxImageUnits = static_cast<Int>(p.limits.maxPerStageDescriptorStorageImages);
|
||||
caps.MaxCombinedImageUniforms = static_cast<Int>(p.limits.maxDescriptorSetStorageImages);
|
||||
caps.MaxComputeImageUniforms = static_cast<Int>(p.limits.maxPerStageDescriptorStorageImages);
|
||||
caps.MaxDrawBuffers = static_cast<Int>(p.limits.maxFragmentOutputAttachments);
|
||||
caps.MaxColorAttachments = static_cast<Int>(p.limits.maxColorAttachments);
|
||||
caps.MaxClipDistances = static_cast<Int>(p.limits.maxClipDistances);
|
||||
caps.MaxViewports = static_cast<Int>(p.limits.maxViewports);
|
||||
caps.MaxViewportWidth = static_cast<Int>(p.limits.maxViewportDimensions[0]);
|
||||
caps.MaxViewportHeight = static_cast<Int>(p.limits.maxViewportDimensions[1]);
|
||||
caps.ViewportBoundsRangeMin = p.limits.viewportBoundsRange[0];
|
||||
caps.ViewportBoundsRangeMax = p.limits.viewportBoundsRange[1];
|
||||
caps.ViewportSubpixelBits = static_cast<Int>(p.limits.viewportSubPixelBits);
|
||||
|
||||
VkPhysicalDeviceFeatures supportedFeatures{};
|
||||
vkGetPhysicalDeviceFeatures(physicalDevice, &supportedFeatures);
|
||||
caps.SupportsWideLines = supportedFeatures.wideLines == VK_TRUE;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -93,5 +167,53 @@ namespace MobileGL::MG_Util::BackendLoader {
|
||||
caps.DeviceName = properties.deviceName;
|
||||
caps.DriverVersionString = DecodeDriverVersion(properties.driverVersion);
|
||||
caps.UniformBufferOffsetAlignment = static_cast<int>(properties.limits.minUniformBufferOffsetAlignment);
|
||||
caps.AliasedLineWidthRangeMin = properties.limits.lineWidthRange[0];
|
||||
caps.AliasedLineWidthRangeMax = properties.limits.lineWidthRange[1];
|
||||
caps.SmoothLineWidthRangeMin = properties.limits.lineWidthRange[0];
|
||||
caps.SmoothLineWidthRangeMax = properties.limits.lineWidthRange[1];
|
||||
caps.SmoothLineWidthGranularity = properties.limits.lineWidthGranularity;
|
||||
caps.PointSizeRangeMin = properties.limits.pointSizeRange[0];
|
||||
caps.PointSizeRangeMax = properties.limits.pointSizeRange[1];
|
||||
caps.PointSizeGranularity = properties.limits.pointSizeGranularity;
|
||||
caps.Max3DTextureSize = static_cast<Int>(properties.limits.maxImageDimension3D);
|
||||
caps.MaxArrayTextureLayers = static_cast<Int>(properties.limits.maxImageArrayLayers);
|
||||
caps.MaxCubeMapTextureSize = static_cast<Int>(properties.limits.maxImageDimensionCube);
|
||||
caps.MaxFramebufferWidth = static_cast<Int>(properties.limits.maxFramebufferWidth);
|
||||
caps.MaxFramebufferHeight = static_cast<Int>(properties.limits.maxFramebufferHeight);
|
||||
caps.MaxFramebufferLayers = static_cast<Int>(properties.limits.maxFramebufferLayers);
|
||||
caps.MaxRenderbufferSize = ResolveMaxRenderbufferSize(properties.limits);
|
||||
caps.MaxTextureSize = static_cast<Int>(properties.limits.maxImageDimension2D);
|
||||
caps.MaxColorTextureSamples = MaxSampleCountFromFlags(properties.limits.sampledImageColorSampleCounts);
|
||||
caps.MaxDepthTextureSamples = MaxSampleCountFromFlags(properties.limits.sampledImageDepthSampleCounts);
|
||||
caps.MaxFramebufferSamples = ResolveConservativeFramebufferSampleLimit(properties.limits);
|
||||
caps.MaxIntegerSamples = MaxSampleCountFromFlags(properties.limits.sampledImageIntegerSampleCounts);
|
||||
caps.MaxSamples = caps.MaxFramebufferSamples;
|
||||
caps.MaxSampleMaskWords = static_cast<Int>(properties.limits.maxSampleMaskWords);
|
||||
caps.MaxTextureImageUnits = static_cast<Int>(properties.limits.maxPerStageDescriptorSampledImages);
|
||||
caps.MaxVertexTextureImageUnits = static_cast<Int>(properties.limits.maxPerStageDescriptorSampledImages);
|
||||
caps.MaxComputeTextureImageUnits = static_cast<Int>(properties.limits.maxPerStageDescriptorSampledImages);
|
||||
caps.MaxCombinedTextureImageUnits = static_cast<Int>(properties.limits.maxDescriptorSetSampledImages);
|
||||
caps.MaxVertexAttribs = static_cast<Int>(properties.limits.maxVertexInputAttributes);
|
||||
caps.MaxComputeShaderStorageBlocks = static_cast<Int>(properties.limits.maxPerStageDescriptorStorageBuffers);
|
||||
caps.MaxCombinedShaderStorageBlocks = static_cast<Int>(properties.limits.maxDescriptorSetStorageBuffers);
|
||||
caps.MaxComputeUniformBlocks = static_cast<Int>(properties.limits.maxPerStageDescriptorUniformBuffers);
|
||||
caps.MaxComputeWorkGroupInvocations = static_cast<Int>(properties.limits.maxComputeWorkGroupInvocations);
|
||||
caps.MaxShaderStorageBufferBindings = static_cast<Int>(properties.limits.maxDescriptorSetStorageBuffers);
|
||||
caps.MaxTextureBufferSize = static_cast<Int>(properties.limits.maxTexelBufferElements);
|
||||
caps.MaxUniformBufferBindings = static_cast<Int>(properties.limits.maxDescriptorSetUniformBuffers);
|
||||
caps.MaxUniformBlockSize = static_cast<Int>(properties.limits.maxUniformBufferRange);
|
||||
caps.MaxImageUnits = static_cast<Int>(properties.limits.maxPerStageDescriptorStorageImages);
|
||||
caps.MaxCombinedImageUniforms = static_cast<Int>(properties.limits.maxDescriptorSetStorageImages);
|
||||
caps.MaxComputeImageUniforms = static_cast<Int>(properties.limits.maxPerStageDescriptorStorageImages);
|
||||
caps.MaxDrawBuffers = static_cast<Int>(properties.limits.maxFragmentOutputAttachments);
|
||||
caps.MaxColorAttachments = static_cast<Int>(properties.limits.maxColorAttachments);
|
||||
caps.MaxClipDistances = static_cast<Int>(properties.limits.maxClipDistances);
|
||||
caps.MaxViewports = static_cast<Int>(properties.limits.maxViewports);
|
||||
caps.MaxViewportWidth = static_cast<Int>(properties.limits.maxViewportDimensions[0]);
|
||||
caps.MaxViewportHeight = static_cast<Int>(properties.limits.maxViewportDimensions[1]);
|
||||
caps.ViewportBoundsRangeMin = properties.limits.viewportBoundsRange[0];
|
||||
caps.ViewportBoundsRangeMax = properties.limits.viewportBoundsRange[1];
|
||||
caps.ViewportSubpixelBits = static_cast<Int>(properties.limits.viewportSubPixelBits);
|
||||
caps.SupportsWideLines = false;
|
||||
}
|
||||
} // namespace MobileGL::MG_Util::BackendLoader
|
||||
|
||||
@@ -16,6 +16,54 @@ namespace MobileGL {
|
||||
String DeviceName;
|
||||
String DriverVersionString;
|
||||
Int UniformBufferOffsetAlignment = 256;
|
||||
Float AliasedLineWidthRangeMin = 1.0f;
|
||||
Float AliasedLineWidthRangeMax = 1.0f;
|
||||
Float SmoothLineWidthRangeMin = 1.0f;
|
||||
Float SmoothLineWidthRangeMax = 1.0f;
|
||||
Float SmoothLineWidthGranularity = 1.0f;
|
||||
Float PointSizeRangeMin = 1.0f;
|
||||
Float PointSizeRangeMax = 1.0f;
|
||||
Float PointSizeGranularity = 1.0f;
|
||||
Int Max3DTextureSize = 16384;
|
||||
Int MaxArrayTextureLayers = 2048;
|
||||
Int MaxCubeMapTextureSize = 16384;
|
||||
Int MaxFramebufferWidth = 16384;
|
||||
Int MaxFramebufferHeight = 16384;
|
||||
Int MaxFramebufferLayers = 2048;
|
||||
Int MaxRenderbufferSize = 16384;
|
||||
Int MaxTextureSize = 16384;
|
||||
Int MaxColorTextureSamples = 1;
|
||||
Int MaxDepthTextureSamples = 1;
|
||||
Int MaxFramebufferSamples = 1;
|
||||
Int MaxIntegerSamples = 1;
|
||||
Int MaxSamples = 1;
|
||||
Int MaxSampleMaskWords = 1;
|
||||
Int MaxTextureImageUnits = 32;
|
||||
Int MaxVertexTextureImageUnits = 32;
|
||||
Int MaxComputeTextureImageUnits = 32;
|
||||
Int MaxCombinedTextureImageUnits = 192;
|
||||
Int MaxVertexAttribs = 16;
|
||||
Int MaxComputeShaderStorageBlocks = 8;
|
||||
Int MaxCombinedShaderStorageBlocks = 32;
|
||||
Int MaxComputeUniformBlocks = 12;
|
||||
Int MaxComputeWorkGroupInvocations = 128;
|
||||
Int MaxShaderStorageBufferBindings = 8;
|
||||
Int MaxTextureBufferSize = 65536;
|
||||
Int MaxUniformBufferBindings = 24;
|
||||
Int MaxUniformBlockSize = 16384;
|
||||
Int MaxImageUnits = 8;
|
||||
Int MaxCombinedImageUniforms = 8;
|
||||
Int MaxComputeImageUniforms = 8;
|
||||
Int MaxDrawBuffers = 8;
|
||||
Int MaxColorAttachments = 8;
|
||||
Int MaxClipDistances = 8;
|
||||
Int MaxViewports = 16;
|
||||
Int MaxViewportWidth = 16384;
|
||||
Int MaxViewportHeight = 16384;
|
||||
Float ViewportBoundsRangeMin = 0.0f;
|
||||
Float ViewportBoundsRangeMax = 0.0f;
|
||||
Int ViewportSubpixelBits = 0;
|
||||
Bool SupportsWideLines = false;
|
||||
};
|
||||
} // namespace MG_External
|
||||
namespace MG_Util::BackendLoader {
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace MobileGL {
|
||||
return DataType::Int32;
|
||||
case GL_UNSIGNED_INT:
|
||||
return DataType::Uint32;
|
||||
case GL_FIXED:
|
||||
return DataType::Fixed32;
|
||||
case GL_HALF_FLOAT:
|
||||
return DataType::Float16;
|
||||
case GL_FLOAT:
|
||||
@@ -35,4 +37,4 @@ namespace MobileGL {
|
||||
}
|
||||
}
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -62,6 +62,45 @@ namespace MobileGL {
|
||||
}
|
||||
}
|
||||
|
||||
LogicOperation ConvertGLEnumToLogicOperation(GLenum v) {
|
||||
switch (v) {
|
||||
case GL_CLEAR:
|
||||
return LogicOperation::Clear;
|
||||
case GL_AND:
|
||||
return LogicOperation::And;
|
||||
case GL_AND_REVERSE:
|
||||
return LogicOperation::AndReverse;
|
||||
case GL_COPY:
|
||||
return LogicOperation::Copy;
|
||||
case GL_AND_INVERTED:
|
||||
return LogicOperation::AndInverted;
|
||||
case GL_NOOP:
|
||||
return LogicOperation::Noop;
|
||||
case GL_XOR:
|
||||
return LogicOperation::Xor;
|
||||
case GL_OR:
|
||||
return LogicOperation::Or;
|
||||
case GL_NOR:
|
||||
return LogicOperation::Nor;
|
||||
case GL_EQUIV:
|
||||
return LogicOperation::Equiv;
|
||||
case GL_INVERT:
|
||||
return LogicOperation::Invert;
|
||||
case GL_OR_REVERSE:
|
||||
return LogicOperation::OrReverse;
|
||||
case GL_COPY_INVERTED:
|
||||
return LogicOperation::CopyInverted;
|
||||
case GL_OR_INVERTED:
|
||||
return LogicOperation::OrInverted;
|
||||
case GL_NAND:
|
||||
return LogicOperation::Nand;
|
||||
case GL_SET:
|
||||
return LogicOperation::Set;
|
||||
default:
|
||||
return LogicOperation::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
DepthTestFunc ConvertGLEnumToDepthTestFunc(GLenum v) {
|
||||
switch (v) {
|
||||
case GL_NEVER:
|
||||
@@ -85,6 +124,29 @@ namespace MobileGL {
|
||||
}
|
||||
}
|
||||
|
||||
StencilOperation ConvertGLEnumToStencilOperation(GLenum v) {
|
||||
switch (v) {
|
||||
case GL_KEEP:
|
||||
return StencilOperation::Keep;
|
||||
case GL_ZERO:
|
||||
return StencilOperation::Zero;
|
||||
case GL_REPLACE:
|
||||
return StencilOperation::Replace;
|
||||
case GL_INCR:
|
||||
return StencilOperation::IncrementClamp;
|
||||
case GL_DECR:
|
||||
return StencilOperation::DecrementClamp;
|
||||
case GL_INVERT:
|
||||
return StencilOperation::Invert;
|
||||
case GL_INCR_WRAP:
|
||||
return StencilOperation::IncrementWrap;
|
||||
case GL_DECR_WRAP:
|
||||
return StencilOperation::DecrementWrap;
|
||||
default:
|
||||
return StencilOperation::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
PixelStoreParam ConvertGLEnumToPixelStoreParam(GLenum v) {
|
||||
switch (v) {
|
||||
case GL_PACK_ALIGNMENT:
|
||||
|
||||
@@ -14,7 +14,9 @@ namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
BlendFactor ConvertGLEnumToBlendFactor(GLenum value);
|
||||
BlendEquation ConvertGLEnumToBlendEquation(GLenum value);
|
||||
LogicOperation ConvertGLEnumToLogicOperation(GLenum value);
|
||||
DepthTestFunc ConvertGLEnumToDepthTestFunc(GLenum value);
|
||||
StencilOperation ConvertGLEnumToStencilOperation(GLenum value);
|
||||
PixelStoreParam ConvertGLEnumToPixelStoreParam(GLenum value);
|
||||
CullFaceMode ConvertGLEnumToCullFaceMode(GLenum value);
|
||||
FrontFaceMode ConvertGLEnumToFrontFaceMode(GLenum value);
|
||||
|
||||
@@ -14,12 +14,16 @@ namespace MobileGL {
|
||||
TextureTarget ConvertGLEnumToTextureTarget(GLenum target) {
|
||||
switch (target) {
|
||||
case GL_TEXTURE_1D:
|
||||
case GL_PROXY_TEXTURE_1D:
|
||||
return TextureTarget::Texture1D;
|
||||
case GL_TEXTURE_2D:
|
||||
case GL_PROXY_TEXTURE_2D:
|
||||
return TextureTarget::Texture2D;
|
||||
case GL_TEXTURE_3D:
|
||||
case GL_PROXY_TEXTURE_3D:
|
||||
return TextureTarget::Texture3D;
|
||||
case GL_TEXTURE_CUBE_MAP:
|
||||
case GL_PROXY_TEXTURE_CUBE_MAP:
|
||||
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
|
||||
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
|
||||
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
|
||||
@@ -28,18 +32,24 @@ namespace MobileGL {
|
||||
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
||||
return TextureTarget::TextureCubeMap;
|
||||
case GL_TEXTURE_2D_ARRAY:
|
||||
case GL_PROXY_TEXTURE_2D_ARRAY:
|
||||
return TextureTarget::Texture2DArray;
|
||||
case GL_TEXTURE_2D_MULTISAMPLE:
|
||||
case GL_PROXY_TEXTURE_2D_MULTISAMPLE:
|
||||
return TextureTarget::Texture2DMultisample;
|
||||
case GL_TEXTURE_CUBE_MAP_ARRAY:
|
||||
case GL_PROXY_TEXTURE_CUBE_MAP_ARRAY:
|
||||
return TextureTarget::TextureCubeMapArray;
|
||||
case GL_TEXTURE_BUFFER:
|
||||
return TextureTarget::TextureBuffer;
|
||||
case GL_TEXTURE_1D_ARRAY:
|
||||
case GL_PROXY_TEXTURE_1D_ARRAY:
|
||||
return TextureTarget::Texture1DArray;
|
||||
case GL_TEXTURE_RECTANGLE:
|
||||
case GL_PROXY_TEXTURE_RECTANGLE:
|
||||
return TextureTarget::TextureRectangle;
|
||||
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
|
||||
case GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY:
|
||||
return TextureTarget::Texture2DMultisampleArray;
|
||||
default:
|
||||
return TextureTarget::Unknown;
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace MobileGL {
|
||||
return GL_INT;
|
||||
case DataType::Uint32:
|
||||
return GL_UNSIGNED_INT;
|
||||
case DataType::Fixed32:
|
||||
return GL_FIXED;
|
||||
case DataType::Float16:
|
||||
return GL_HALF_FLOAT;
|
||||
case DataType::Float32:
|
||||
@@ -35,4 +37,4 @@ namespace MobileGL {
|
||||
}
|
||||
}
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -16,8 +16,9 @@ namespace MobileGL {
|
||||
return GL_DRAW_FRAMEBUFFER;
|
||||
case FramebufferTarget::Read:
|
||||
return GL_READ_FRAMEBUFFER;
|
||||
case FramebufferTarget::Unknown:
|
||||
default:
|
||||
return GL_DRAW_FRAMEBUFFER;
|
||||
return GL_UNKNOWN_MGL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +30,8 @@ namespace MobileGL {
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case FramebufferAttachmentType::None:
|
||||
return GL_NONE;
|
||||
case FramebufferAttachmentType::Depth:
|
||||
return GL_DEPTH_ATTACHMENT;
|
||||
case FramebufferAttachmentType::Stencil:
|
||||
@@ -41,8 +44,9 @@ namespace MobileGL {
|
||||
return GL_BACK_LEFT;
|
||||
case FramebufferAttachmentType::BackRight:
|
||||
return GL_BACK_RIGHT;
|
||||
case FramebufferAttachmentType::Unknown:
|
||||
default:
|
||||
return GL_NONE;
|
||||
return GL_UNKNOWN_MGL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,10 +54,11 @@ namespace MobileGL {
|
||||
switch (target) {
|
||||
case RenderbufferTarget::Renderbuffer:
|
||||
return GL_RENDERBUFFER;
|
||||
case RenderbufferTarget::Unknown:
|
||||
default:
|
||||
return GL_RENDERBUFFER;
|
||||
return GL_UNKNOWN_MGL;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -63,6 +63,45 @@ namespace MobileGL {
|
||||
}
|
||||
}
|
||||
|
||||
GLenum ConvertLogicOperationToGLEnum(LogicOperation v) {
|
||||
switch (v) {
|
||||
case LogicOperation::Clear:
|
||||
return GL_CLEAR;
|
||||
case LogicOperation::And:
|
||||
return GL_AND;
|
||||
case LogicOperation::AndReverse:
|
||||
return GL_AND_REVERSE;
|
||||
case LogicOperation::Copy:
|
||||
return GL_COPY;
|
||||
case LogicOperation::AndInverted:
|
||||
return GL_AND_INVERTED;
|
||||
case LogicOperation::Noop:
|
||||
return GL_NOOP;
|
||||
case LogicOperation::Xor:
|
||||
return GL_XOR;
|
||||
case LogicOperation::Or:
|
||||
return GL_OR;
|
||||
case LogicOperation::Nor:
|
||||
return GL_NOR;
|
||||
case LogicOperation::Equiv:
|
||||
return GL_EQUIV;
|
||||
case LogicOperation::Invert:
|
||||
return GL_INVERT;
|
||||
case LogicOperation::OrReverse:
|
||||
return GL_OR_REVERSE;
|
||||
case LogicOperation::CopyInverted:
|
||||
return GL_COPY_INVERTED;
|
||||
case LogicOperation::OrInverted:
|
||||
return GL_OR_INVERTED;
|
||||
case LogicOperation::Nand:
|
||||
return GL_NAND;
|
||||
case LogicOperation::Set:
|
||||
return GL_SET;
|
||||
default:
|
||||
return GL_UNKNOWN_MGL;
|
||||
}
|
||||
}
|
||||
|
||||
GLenum ConvertDepthTestFuncToGLEnum(DepthTestFunc v) {
|
||||
switch (v) {
|
||||
case DepthTestFunc::Never:
|
||||
@@ -86,6 +125,29 @@ namespace MobileGL {
|
||||
}
|
||||
}
|
||||
|
||||
GLenum ConvertStencilOperationToGLEnum(StencilOperation v) {
|
||||
switch (v) {
|
||||
case StencilOperation::Keep:
|
||||
return GL_KEEP;
|
||||
case StencilOperation::Zero:
|
||||
return GL_ZERO;
|
||||
case StencilOperation::Replace:
|
||||
return GL_REPLACE;
|
||||
case StencilOperation::IncrementClamp:
|
||||
return GL_INCR;
|
||||
case StencilOperation::DecrementClamp:
|
||||
return GL_DECR;
|
||||
case StencilOperation::Invert:
|
||||
return GL_INVERT;
|
||||
case StencilOperation::IncrementWrap:
|
||||
return GL_INCR_WRAP;
|
||||
case StencilOperation::DecrementWrap:
|
||||
return GL_DECR_WRAP;
|
||||
default:
|
||||
return GL_UNKNOWN_MGL;
|
||||
}
|
||||
}
|
||||
|
||||
GLenum ConvertPixelStoreParamToGLEnum(PixelStoreParam v) {
|
||||
switch (v) {
|
||||
case PixelStoreParam::PackAlignment:
|
||||
|
||||
@@ -14,7 +14,9 @@ namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
GLenum ConvertBlendFactorToGLEnum(BlendFactor value);
|
||||
GLenum ConvertBlendEquationToGLEnum(BlendEquation value);
|
||||
GLenum ConvertLogicOperationToGLEnum(LogicOperation value);
|
||||
GLenum ConvertDepthTestFuncToGLEnum(DepthTestFunc value);
|
||||
GLenum ConvertStencilOperationToGLEnum(StencilOperation value);
|
||||
GLenum ConvertPixelStoreParamToGLEnum(PixelStoreParam value);
|
||||
GLenum ConvertCullFaceModeToGLEnum(CullFaceMode value);
|
||||
GLenum ConvertFrontFaceModeToGLEnum(FrontFaceMode value);
|
||||
|
||||
@@ -110,6 +110,8 @@ namespace MobileGL {
|
||||
return GL_RGB10;
|
||||
case TextureInternalFormat::RGB12:
|
||||
return GL_RGB12;
|
||||
case TextureInternalFormat::RGB16:
|
||||
return GL_RGB16;
|
||||
case TextureInternalFormat::RGB16Snorm:
|
||||
return GL_RGB16_SNORM;
|
||||
case TextureInternalFormat::RGBA2:
|
||||
@@ -267,6 +269,8 @@ namespace MobileGL {
|
||||
return GL_UNSIGNED_SHORT_5_5_5_1;
|
||||
case TexturePixelDataType::UnsignedShort1555Rev:
|
||||
return GL_UNSIGNED_SHORT_1_5_5_5_REV;
|
||||
case TexturePixelDataType::UnsignedInt8888:
|
||||
return GL_UNSIGNED_INT_8_8_8_8;
|
||||
case TexturePixelDataType::UnsignedInt8888Rev:
|
||||
return GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
case TexturePixelDataType::UnsignedInt1010102:
|
||||
|
||||
@@ -72,6 +72,10 @@ namespace MobileGL {
|
||||
}
|
||||
|
||||
String ConvertBufferMappingAccessToString(Flags<BufferMappingAccessBit> access) {
|
||||
if (access == BufferMappingAccessBit::Null) {
|
||||
return "[]";
|
||||
}
|
||||
|
||||
String result = "[";
|
||||
if (access & BufferMappingAccessBit::Read) result += "Read, ";
|
||||
if (access & BufferMappingAccessBit::Write) result += "Write, ";
|
||||
@@ -84,7 +88,7 @@ namespace MobileGL {
|
||||
result.pop_back();
|
||||
result.pop_back();
|
||||
result += "]";
|
||||
return result.empty() ? "[]" : result;
|
||||
return result;
|
||||
}
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -29,6 +29,16 @@ namespace MobileGL {
|
||||
}
|
||||
|
||||
switch (attachment) {
|
||||
case FramebufferAttachmentType::None:
|
||||
return "None";
|
||||
case FramebufferAttachmentType::FrontLeft:
|
||||
return "FrontLeft";
|
||||
case FramebufferAttachmentType::FrontRight:
|
||||
return "FrontRight";
|
||||
case FramebufferAttachmentType::BackLeft:
|
||||
return "BackLeft";
|
||||
case FramebufferAttachmentType::BackRight:
|
||||
return "BackRight";
|
||||
case FramebufferAttachmentType::Depth:
|
||||
return "Depth";
|
||||
case FramebufferAttachmentType::Stencil:
|
||||
@@ -49,4 +59,4 @@ namespace MobileGL {
|
||||
}
|
||||
}
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -45,6 +45,45 @@ namespace MobileGL {
|
||||
}
|
||||
}
|
||||
|
||||
String ConvertLogicOperationToString(LogicOperation v) {
|
||||
switch (v) {
|
||||
case LogicOperation::Clear:
|
||||
return "Clear";
|
||||
case LogicOperation::And:
|
||||
return "And";
|
||||
case LogicOperation::AndReverse:
|
||||
return "AndReverse";
|
||||
case LogicOperation::Copy:
|
||||
return "Copy";
|
||||
case LogicOperation::AndInverted:
|
||||
return "AndInverted";
|
||||
case LogicOperation::Noop:
|
||||
return "Noop";
|
||||
case LogicOperation::Xor:
|
||||
return "Xor";
|
||||
case LogicOperation::Or:
|
||||
return "Or";
|
||||
case LogicOperation::Nor:
|
||||
return "Nor";
|
||||
case LogicOperation::Equiv:
|
||||
return "Equiv";
|
||||
case LogicOperation::Invert:
|
||||
return "Invert";
|
||||
case LogicOperation::OrReverse:
|
||||
return "OrReverse";
|
||||
case LogicOperation::CopyInverted:
|
||||
return "CopyInverted";
|
||||
case LogicOperation::OrInverted:
|
||||
return "OrInverted";
|
||||
case LogicOperation::Nand:
|
||||
return "Nand";
|
||||
case LogicOperation::Set:
|
||||
return "Set";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
String ConvertDepthTestFuncToString(DepthTestFunc v) {
|
||||
switch (v) {
|
||||
case DepthTestFunc::Never:
|
||||
@@ -68,6 +107,29 @@ namespace MobileGL {
|
||||
}
|
||||
}
|
||||
|
||||
String ConvertStencilOperationToString(StencilOperation v) {
|
||||
switch (v) {
|
||||
case StencilOperation::Keep:
|
||||
return "Keep";
|
||||
case StencilOperation::Zero:
|
||||
return "Zero";
|
||||
case StencilOperation::Replace:
|
||||
return "Replace";
|
||||
case StencilOperation::IncrementClamp:
|
||||
return "IncrementClamp";
|
||||
case StencilOperation::DecrementClamp:
|
||||
return "DecrementClamp";
|
||||
case StencilOperation::Invert:
|
||||
return "Invert";
|
||||
case StencilOperation::IncrementWrap:
|
||||
return "IncrementWrap";
|
||||
case StencilOperation::DecrementWrap:
|
||||
return "DecrementWrap";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
String ConvertPixelStoreParamToString(PixelStoreParam v) {
|
||||
switch (v) {
|
||||
case PixelStoreParam::PackAlignment:
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
String ConvertBlendFactorToString(BlendFactor value);
|
||||
String ConvertLogicOperationToString(LogicOperation value);
|
||||
String ConvertDepthTestFuncToString(DepthTestFunc value);
|
||||
String ConvertStencilOperationToString(StencilOperation value);
|
||||
String ConvertPixelStoreParamToString(PixelStoreParam value);
|
||||
String ConvertCullFaceModeToString(CullFaceMode value);
|
||||
String ConvertFrontFaceModeToString(FrontFaceMode value);
|
||||
|
||||
@@ -110,6 +110,8 @@ namespace MobileGL {
|
||||
return "RGB10";
|
||||
case TextureInternalFormat::RGB12:
|
||||
return "RGB12";
|
||||
case TextureInternalFormat::RGB16:
|
||||
return "RGB16";
|
||||
case TextureInternalFormat::RGB16Snorm:
|
||||
return "RGB16Snorm";
|
||||
case TextureInternalFormat::RGBA2:
|
||||
|
||||
@@ -47,6 +47,45 @@ namespace MobileGL {
|
||||
}
|
||||
}
|
||||
|
||||
VkLogicOp ConvertLogicOperationToVkEnum(LogicOperation v) {
|
||||
switch (v) {
|
||||
case LogicOperation::Clear:
|
||||
return VK_LOGIC_OP_CLEAR;
|
||||
case LogicOperation::And:
|
||||
return VK_LOGIC_OP_AND;
|
||||
case LogicOperation::AndReverse:
|
||||
return VK_LOGIC_OP_AND_REVERSE;
|
||||
case LogicOperation::Copy:
|
||||
return VK_LOGIC_OP_COPY;
|
||||
case LogicOperation::AndInverted:
|
||||
return VK_LOGIC_OP_AND_INVERTED;
|
||||
case LogicOperation::Noop:
|
||||
return VK_LOGIC_OP_NO_OP;
|
||||
case LogicOperation::Xor:
|
||||
return VK_LOGIC_OP_XOR;
|
||||
case LogicOperation::Or:
|
||||
return VK_LOGIC_OP_OR;
|
||||
case LogicOperation::Nor:
|
||||
return VK_LOGIC_OP_NOR;
|
||||
case LogicOperation::Equiv:
|
||||
return VK_LOGIC_OP_EQUIVALENT;
|
||||
case LogicOperation::Invert:
|
||||
return VK_LOGIC_OP_INVERT;
|
||||
case LogicOperation::OrReverse:
|
||||
return VK_LOGIC_OP_OR_REVERSE;
|
||||
case LogicOperation::CopyInverted:
|
||||
return VK_LOGIC_OP_COPY_INVERTED;
|
||||
case LogicOperation::OrInverted:
|
||||
return VK_LOGIC_OP_OR_INVERTED;
|
||||
case LogicOperation::Nand:
|
||||
return VK_LOGIC_OP_NAND;
|
||||
case LogicOperation::Set:
|
||||
return VK_LOGIC_OP_SET;
|
||||
default:
|
||||
return VK_LOGIC_OP_COPY;
|
||||
}
|
||||
}
|
||||
|
||||
VkCompareOp ConvertDepthTestFuncToVkEnum(DepthTestFunc v) {
|
||||
switch (v) {
|
||||
case DepthTestFunc::Never:
|
||||
@@ -69,6 +108,29 @@ namespace MobileGL {
|
||||
}
|
||||
}
|
||||
|
||||
VkStencilOp ConvertStencilOperationToVkEnum(StencilOperation v) {
|
||||
switch (v) {
|
||||
case StencilOperation::Keep:
|
||||
return VK_STENCIL_OP_KEEP;
|
||||
case StencilOperation::Zero:
|
||||
return VK_STENCIL_OP_ZERO;
|
||||
case StencilOperation::Replace:
|
||||
return VK_STENCIL_OP_REPLACE;
|
||||
case StencilOperation::IncrementClamp:
|
||||
return VK_STENCIL_OP_INCREMENT_AND_CLAMP;
|
||||
case StencilOperation::DecrementClamp:
|
||||
return VK_STENCIL_OP_DECREMENT_AND_CLAMP;
|
||||
case StencilOperation::Invert:
|
||||
return VK_STENCIL_OP_INVERT;
|
||||
case StencilOperation::IncrementWrap:
|
||||
return VK_STENCIL_OP_INCREMENT_AND_WRAP;
|
||||
case StencilOperation::DecrementWrap:
|
||||
return VK_STENCIL_OP_DECREMENT_AND_WRAP;
|
||||
default:
|
||||
return VK_STENCIL_OP_KEEP;
|
||||
}
|
||||
}
|
||||
|
||||
VkBlendFactor ConvertBlendFactorToVkEnum(BlendFactor v) {
|
||||
switch (v) {
|
||||
case BlendFactor::Zero:
|
||||
|
||||
@@ -14,7 +14,9 @@ namespace MobileGL {
|
||||
namespace MG_Util {
|
||||
VkPrimitiveTopology ConvertPrimitiveModeToVkEnum(GLenum mode);
|
||||
VkCullModeFlags ConvertCullFaceModeToVkEnum(CullFaceMode value, Bool invertClockwise = false);
|
||||
VkLogicOp ConvertLogicOperationToVkEnum(LogicOperation value);
|
||||
VkCompareOp ConvertDepthTestFuncToVkEnum(DepthTestFunc value);
|
||||
VkStencilOp ConvertStencilOperationToVkEnum(StencilOperation value);
|
||||
VkBlendFactor ConvertBlendFactorToVkEnum(BlendFactor value);
|
||||
VkBlendOp ConvertBlendEquationToVkEnum(BlendEquation value);
|
||||
} // namespace MG_Util
|
||||
|
||||
@@ -95,11 +95,13 @@ namespace MobileGL {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
int n = std::vsnprintf(buffer, sizeof(buffer), fmt, args);
|
||||
const SizeT messageLength =
|
||||
(n < 0) ? 0 : std::min(static_cast<SizeT>(n), sizeof(buffer) - static_cast<SizeT>(1));
|
||||
std::string out = header +
|
||||
#if MOBILEGL_LOG_ENABLE_STACKTRACE
|
||||
padding +
|
||||
#endif
|
||||
std::string(buffer, n) + "\n";
|
||||
std::string(buffer, messageLength) + "\n";
|
||||
|
||||
#if MOBILEGL_LOG_ENABLE_CONSOLE
|
||||
std::fwrite(out.c_str(), 1, out.size(), stdout);
|
||||
|
||||
@@ -43,6 +43,10 @@ namespace MobileGL {
|
||||
case TextureInternalFormat::DepthComponent24:
|
||||
return 3;
|
||||
|
||||
case TextureInternalFormat::RGB10:
|
||||
case TextureInternalFormat::RGB12:
|
||||
case TextureInternalFormat::RGB16:
|
||||
case TextureInternalFormat::RGB16Snorm:
|
||||
case TextureInternalFormat::RGBA2:
|
||||
case TextureInternalFormat::RGBA4:
|
||||
case TextureInternalFormat::RGB5A1:
|
||||
@@ -54,6 +58,8 @@ namespace MobileGL {
|
||||
case TextureInternalFormat::RGB10A2:
|
||||
case TextureInternalFormat::RGB10A2UI:
|
||||
case TextureInternalFormat::R32F:
|
||||
case TextureInternalFormat::R32I:
|
||||
case TextureInternalFormat::R32UI:
|
||||
case TextureInternalFormat::DepthComponent:
|
||||
case TextureInternalFormat::DepthComponent32:
|
||||
case TextureInternalFormat::DepthComponent32F:
|
||||
@@ -179,6 +185,7 @@ namespace MobileGL {
|
||||
case TextureInternalFormat::RGB10:
|
||||
case TextureInternalFormat::RGB12:
|
||||
case TextureInternalFormat::RGB16:
|
||||
case TextureInternalFormat::RGB16Snorm:
|
||||
case TextureInternalFormat::SRGB8:
|
||||
case TextureInternalFormat::RGB8I:
|
||||
case TextureInternalFormat::RGB8UI:
|
||||
@@ -236,7 +243,6 @@ namespace MobileGL {
|
||||
case TexturePixelDataType::UnsignedInt248:
|
||||
case TexturePixelDataType::Float32UnsignedInt248Rev:
|
||||
return 4;
|
||||
return 4;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -339,6 +345,22 @@ namespace MobileGL {
|
||||
s.Green = 8;
|
||||
s.Blue = 8;
|
||||
break;
|
||||
case TextureInternalFormat::RGB10:
|
||||
s.Red = 10;
|
||||
s.Green = 10;
|
||||
s.Blue = 10;
|
||||
break;
|
||||
case TextureInternalFormat::RGB12:
|
||||
s.Red = 12;
|
||||
s.Green = 12;
|
||||
s.Blue = 12;
|
||||
break;
|
||||
case TextureInternalFormat::RGB16:
|
||||
case TextureInternalFormat::RGB16Snorm:
|
||||
s.Red = 16;
|
||||
s.Green = 16;
|
||||
s.Blue = 16;
|
||||
break;
|
||||
|
||||
case TextureInternalFormat::R3G3B2:
|
||||
s.Red = 3;
|
||||
@@ -370,7 +392,6 @@ namespace MobileGL {
|
||||
case TextureInternalFormat::RGBA8UI:
|
||||
case TextureInternalFormat::SRGB8Alpha8:
|
||||
case TextureInternalFormat::RGBA:
|
||||
break;
|
||||
s.Red = 8;
|
||||
s.Green = 8;
|
||||
s.Blue = 8;
|
||||
@@ -385,6 +406,8 @@ namespace MobileGL {
|
||||
break;
|
||||
|
||||
case TextureInternalFormat::R32F:
|
||||
case TextureInternalFormat::R32I:
|
||||
case TextureInternalFormat::R32UI:
|
||||
s.Red = 32;
|
||||
break;
|
||||
case TextureInternalFormat::RG32F:
|
||||
|
||||
@@ -200,6 +200,10 @@ namespace MobileGL {
|
||||
size_t commentStartPos = source.find("/*");
|
||||
while (commentStartPos != String::npos) {
|
||||
size_t commentEndPos = source.find("*/", commentStartPos);
|
||||
if (commentEndPos == String::npos) {
|
||||
source.erase(commentStartPos);
|
||||
break;
|
||||
}
|
||||
// + length of "*/"
|
||||
source = source.replace(commentStartPos, commentEndPos - commentStartPos + 2, "");
|
||||
commentStartPos = source.find("/*", commentStartPos);
|
||||
|
||||
@@ -120,11 +120,27 @@ namespace MobileGL {
|
||||
less_operands.push_back({SPV_OPERAND_TYPE_ID, {abs_inst->result_id()}});
|
||||
less_operands.push_back({SPV_OPERAND_TYPE_ID, {eps_id}});
|
||||
|
||||
bool isEqualOp =
|
||||
(inst.opcode() == spv::Op::OpFOrdEqual || inst.opcode() == spv::Op::OpFUnordEqual);
|
||||
spv::Op replacementOp = spv::Op::OpNop;
|
||||
switch (inst.opcode()) {
|
||||
case spv::Op::OpFOrdEqual:
|
||||
replacementOp = spv::Op::OpFOrdLessThan;
|
||||
break;
|
||||
case spv::Op::OpFUnordEqual:
|
||||
replacementOp = spv::Op::OpFUnordLessThan;
|
||||
break;
|
||||
case spv::Op::OpFOrdNotEqual:
|
||||
replacementOp = spv::Op::OpFOrdGreaterThanEqual;
|
||||
break;
|
||||
case spv::Op::OpFUnordNotEqual:
|
||||
replacementOp = spv::Op::OpFUnordGreaterThanEqual;
|
||||
break;
|
||||
default:
|
||||
MOBILEGL_ASSERT(false, "Unexpected float compare opcode: %d",
|
||||
static_cast<int>(inst.opcode()));
|
||||
break;
|
||||
}
|
||||
Instruction* less_than_inst = builder.AddInstruction(MakeUnique<Instruction>(
|
||||
context(), isEqualOp ? spv::Op::OpFOrdLessThan : spv::Op::OpFOrdGreaterThanEqual,
|
||||
bool_type_id, context()->TakeNextId(), less_operands));
|
||||
context(), replacementOp, bool_type_id, context()->TakeNextId(), less_operands));
|
||||
|
||||
// 5. Replaces all uses of old insn with new one
|
||||
context()->ReplaceAllUsesWith(inst.result_id(), less_than_inst->result_id());
|
||||
@@ -149,4 +165,4 @@ namespace MobileGL {
|
||||
}
|
||||
} // namespace ShaderTranspiler
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace MobileGL {
|
||||
|
||||
class SpvcSession {
|
||||
public:
|
||||
SpvcSession() {}
|
||||
SpvcSession() = default;
|
||||
|
||||
explicit SpvcSession(const Vector<unsigned int>& spirv,
|
||||
Flags<SessionUsageBit> usage);
|
||||
@@ -97,7 +97,7 @@ namespace MobileGL {
|
||||
spvc_result ParseMetaData();
|
||||
|
||||
private:
|
||||
Flags<SessionUsageBit> usage;
|
||||
Flags<SessionUsageBit> usage{};
|
||||
|
||||
// SPIRV-Cross state (used when Transpile flag is set)
|
||||
spvc_context context = nullptr;
|
||||
@@ -114,4 +114,4 @@ namespace MobileGL {
|
||||
};
|
||||
} // namespace ShaderTranspiler
|
||||
} // namespace MG_Util
|
||||
} // namespace MobileGL
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -154,8 +154,8 @@ namespace MobileGL::MG_Util::PixelStoreProcessor {
|
||||
MGLOG_D("%s: Swizzle (BGRA)", __func__);
|
||||
// MGLOG_D("%s: pixel0 before = %x", __func__, *((Uint32*)layerDst));
|
||||
ProcessColorSwizzle(layerDst, static_cast<SizeT>(copyWidth),
|
||||
{TextureSwizzleParam::Green, TextureSwizzleParam::Blue,
|
||||
TextureSwizzleParam::Alpha, TextureSwizzleParam::Red});
|
||||
{TextureSwizzleParam::Blue, TextureSwizzleParam::Green,
|
||||
TextureSwizzleParam::Red, TextureSwizzleParam::Alpha});
|
||||
// MGLOG_D("%s: pixel0 after = %x", __func__, *((Uint32*)layerDst));
|
||||
}
|
||||
// else
|
||||
|
||||
@@ -157,6 +157,9 @@ namespace MobileGL::MG_Util::TextureFormatProcessor {
|
||||
case GL_SRGB8:
|
||||
*outFormat = GL_RGB;
|
||||
break;
|
||||
case GL_SRGB8_ALPHA8:
|
||||
*outFormat = GL_RGBA;
|
||||
break;
|
||||
|
||||
// Color sized other
|
||||
case GL_RGB9_E5:
|
||||
@@ -178,6 +181,7 @@ namespace MobileGL::MG_Util::TextureFormatProcessor {
|
||||
break;
|
||||
|
||||
// Depth Stencil
|
||||
case GL_DEPTH24_STENCIL8:
|
||||
case GL_DEPTH32F_STENCIL8:
|
||||
case GL_DEPTH_STENCIL:
|
||||
*outFormat = GL_DEPTH_STENCIL;
|
||||
@@ -298,6 +302,9 @@ namespace MobileGL::MG_Util::TextureFormatProcessor {
|
||||
case GL_SRGB8:
|
||||
*outType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case GL_SRGB8_ALPHA8:
|
||||
*outType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
|
||||
// Color sized other
|
||||
case GL_RGB9_E5:
|
||||
@@ -331,6 +338,9 @@ namespace MobileGL::MG_Util::TextureFormatProcessor {
|
||||
break;
|
||||
|
||||
// Depth Stencil
|
||||
case GL_DEPTH24_STENCIL8:
|
||||
*outType = GL_UNSIGNED_INT_24_8;
|
||||
break;
|
||||
case GL_DEPTH32F_STENCIL8:
|
||||
case GL_DEPTH_STENCIL:
|
||||
*outType = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
|
||||
@@ -345,4 +355,4 @@ namespace MobileGL::MG_Util::TextureFormatProcessor {
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace MobileGL::MG_Util::TextureFormatProcessor
|
||||
} // namespace MobileGL::MG_Util::TextureFormatProcessor
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace MobileGL {
|
||||
// represents a range of [start, end)
|
||||
struct Range1D {
|
||||
SizeT start = 0;
|
||||
SizeT end = ~0u;
|
||||
SizeT end = ~SizeT(0);
|
||||
|
||||
void Update(SizeT newStart, SizeT newEnd) {
|
||||
MOBILEGL_ASSERT(newStart <= newEnd, "Range1D::Update: newStart (%zu) > newEnd (%zu)", newStart, newEnd);
|
||||
|
||||
Reference in New Issue
Block a user