mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 14:18:31 +09:00
Merge branch 'Feat/dev-es-shittily-draw' into dev-es without ShittilyDraw
# Conflict: # MG/Includes.h # Changes: # Remove ShittilyDraw, ready to implement MG_RHI... # Update progress.
This commit is contained in:
@@ -1206,6 +1206,15 @@ void Log##name(const char* format, ...) { \
|
||||
CASE(GL_DOT3_RGBA)
|
||||
/* texture_border_clamp */
|
||||
CASE(GL_CLAMP_TO_BORDER)
|
||||
/* framebuffer_status */
|
||||
CASE(GL_FRAMEBUFFER_COMPLETE)
|
||||
CASE(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT)
|
||||
CASE(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT)
|
||||
CASE(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS)
|
||||
CASE(GL_FRAMEBUFFER_UNSUPPORTED)
|
||||
CASE(GL_COLOR_ATTACHMENT0)
|
||||
CASE(GL_DEPTH_ATTACHMENT)
|
||||
CASE(GL_STENCIL_ATTACHMENT)
|
||||
/*
|
||||
* Miscellaneous
|
||||
*/
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace MG_Util::Program {
|
||||
std::ostringstream ss;
|
||||
ss << "[";
|
||||
|
||||
const size_t elemCount = std::min<size_t>(value.count, 16); // 限制最大显示元素
|
||||
const size_t elemCount = std::min<size_t>(value.count, 16);
|
||||
|
||||
switch(value.type) {
|
||||
case GL_FLOAT:
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace MG_Util::Program {
|
||||
return;
|
||||
}
|
||||
|
||||
std::unordered_set<GLint> used_locations;
|
||||
ankerl::unordered_set<GLint> used_locations;
|
||||
GLint auto_location = 0;
|
||||
for (auto spirv: allSpirv) {
|
||||
spvc_parsed_ir ir = nullptr;
|
||||
@@ -395,11 +395,44 @@ namespace MG_Util::Program {
|
||||
prog.uniformLocations[name] = final_location;
|
||||
UniformValue uniformValue;
|
||||
uniformValue.type = gl_type;
|
||||
uniformValue.count = spvc_type_get_array_dimension(type, 0) > 0 ?
|
||||
spvc_type_get_array_dimension(type, 0) : 1;
|
||||
prog.uniformValues[name] = uniformValue;
|
||||
}
|
||||
}
|
||||
spvc_context_destroy(context);
|
||||
}
|
||||
|
||||
std::string CompileSPIRVToGLSL(std::vector<unsigned int> spirv, uint glslVersion, bool isES) {
|
||||
spvc_context context = nullptr;
|
||||
spvc_parsed_ir ir = nullptr;
|
||||
spvc_compiler compiler_glsl = nullptr;
|
||||
spvc_compiler_options options = nullptr;
|
||||
spvc_resources resources = nullptr;
|
||||
const spvc_reflected_resource *list = nullptr;
|
||||
const char *result = nullptr;
|
||||
size_t count;
|
||||
|
||||
const SpvId *p_spirv = spirv.data();
|
||||
size_t word_count = spirv.size();
|
||||
|
||||
spvc_context_create(&context);
|
||||
spvc_context_parse_spirv(context, p_spirv, word_count, &ir);
|
||||
spvc_context_create_compiler(context, SPVC_BACKEND_GLSL, ir, SPVC_CAPTURE_MODE_TAKE_OWNERSHIP, &compiler_glsl);
|
||||
spvc_compiler_create_shader_resources(compiler_glsl, &resources);
|
||||
spvc_resources_get_resource_list_for_type(resources, SPVC_RESOURCE_TYPE_UNIFORM_BUFFER, &list, &count);
|
||||
spvc_compiler_create_compiler_options(compiler_glsl, &options);
|
||||
spvc_compiler_options_set_uint(options, SPVC_COMPILER_OPTION_GLSL_VERSION, glslVersion);
|
||||
spvc_compiler_options_set_bool(options, SPVC_COMPILER_OPTION_GLSL_ES, isES ? SPVC_TRUE : SPVC_FALSE);
|
||||
spvc_compiler_install_compiler_options(compiler_glsl, options);
|
||||
spvc_compiler_compile(compiler_glsl, &result);
|
||||
|
||||
if (!result) {
|
||||
return{};
|
||||
}
|
||||
|
||||
std::string essl = result;
|
||||
|
||||
spvc_context_destroy(context);
|
||||
|
||||
return essl;
|
||||
}
|
||||
}
|
||||
@@ -177,6 +177,7 @@ namespace MG_Util::Program {
|
||||
std::string CompileGLSLToTShader(GLenum shaderType, const std::string& source, glslang::TShader *&shader);
|
||||
std::vector<std::vector<unsigned>> CompileMultipleShadersToSPIRV(const ProgramState& state, ProgramObject& prog, std::string& infoLog);
|
||||
void ReflectSPIRVUniforms(const std::vector<std::vector<unsigned>>& allSpirv, ProgramObject& prog, std::string& infoLog);
|
||||
std::string CompileSPIRVToGLSL(std::vector<unsigned int> spirv, uint glslVersion, bool isES);
|
||||
}
|
||||
|
||||
#endif //MOBILEGL_GLSLTOOL_H
|
||||
|
||||
Reference in New Issue
Block a user