diff options
author | clayjohn <claynjohn@gmail.com> | 2022-11-07 22:40:03 -0800 |
---|---|---|
committer | clayjohn <claynjohn@gmail.com> | 2022-11-14 23:28:25 -0800 |
commit | 9ce57050a5d12776deedd44fcb82dd5841a56686 (patch) | |
tree | a078f43091d787f0d985ee5c1a950fc0962eeaab /gles3_builders.py | |
parent | 98e0d599529aee2b090d84acbd9aaa28572c0da8 (diff) | |
download | redot-engine-9ce57050a5d12776deedd44fcb82dd5841a56686.tar.gz |
Add GPUParticles to the OpenGL3 renderer.
This includes collision (2D SDF, Box, Sphere, Heightmap),
attraction (Box, Sphere), and all sorting modes.
This does not include 3D SDF collisions, trails, or
manual emission.
Diffstat (limited to 'gles3_builders.py')
-rw-r--r-- | gles3_builders.py | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/gles3_builders.py b/gles3_builders.py index 46ab1bbc03..0d0037dea1 100644 --- a/gles3_builders.py +++ b/gles3_builders.py @@ -20,6 +20,7 @@ class GLES3HeaderStruct: self.texunit_names = [] self.ubos = [] self.ubo_names = [] + self.feedbacks = [] self.vertex_included_files = [] self.fragment_included_files = [] @@ -168,6 +169,20 @@ def include_file_in_gles3_header(filename: str, header_data: GLES3HeaderStruct, if not x in header_data.uniforms: header_data.uniforms += [x] + if (line.strip().find("out ") == 0 or line.strip().find("flat ") == 0) and line.find("tfb:") != -1: + uline = line.replace("flat ", "") + uline = uline.replace("out ", "") + uline = uline.replace("highp ", "") + uline = uline.replace(";", "") + uline = uline[uline.find(" ") :].strip() + + if uline.find("//") != -1: + name, bind = uline.split("//") + if bind.find("tfb:") != -1: + name = name.strip() + bind = bind.replace("tfb:", "").strip() + header_data.feedbacks += [(name, bind)] + line = line.replace("\r", "") line = line.replace("\n", "") @@ -240,11 +255,11 @@ def build_gles3_header(filename: str, include: str, class_suffix: str, header_da defspec |= 1 << i fd.write( - "\t_FORCE_INLINE_ void version_bind_shader(RID p_version,ShaderVariant p_variant" + "\t_FORCE_INLINE_ bool version_bind_shader(RID p_version,ShaderVariant p_variant" + defvariant + ",uint64_t p_specialization=" + str(defspec) - + ") { _version_bind_shader(p_version,p_variant,p_specialization); }\n\n" + + ") { return _version_bind_shader(p_version,p_variant,p_specialization); }\n\n" ) if header_data.uniforms: @@ -278,7 +293,7 @@ def build_gles3_header(filename: str, include: str, class_suffix: str, header_da + defvariant + ",uint64_t p_specialization=" + str(defspec) - + ") { _FU glUniform1i(version_get_uniform(p_uniform,p_version,p_variant,p_specialization),p_value); }\n\n" + + ") { _FU glUniform1ui(version_get_uniform(p_uniform,p_version,p_variant,p_specialization),p_value); }\n\n" ) fd.write( "\t_FORCE_INLINE_ void version_set_uniform(Uniforms p_uniform, int8_t p_value,RID p_version,ShaderVariant p_variant" @@ -292,7 +307,7 @@ def build_gles3_header(filename: str, include: str, class_suffix: str, header_da + defvariant + ",uint64_t p_specialization=" + str(defspec) - + ") { _FU glUniform1i(version_get_uniform(p_uniform,p_version,p_variant,p_specialization),p_value); }\n\n" + + ") { _FU glUniform1ui(version_get_uniform(p_uniform,p_version,p_variant,p_specialization),p_value); }\n\n" ) fd.write( "\t_FORCE_INLINE_ void version_set_uniform(Uniforms p_uniform, int16_t p_value,RID p_version,ShaderVariant p_variant" @@ -306,7 +321,7 @@ def build_gles3_header(filename: str, include: str, class_suffix: str, header_da + defvariant + ",uint64_t p_specialization=" + str(defspec) - + ") { _FU glUniform1i(version_get_uniform(p_uniform,p_version,p_variant,p_specialization),p_value); }\n\n" + + ") { _FU glUniform1ui(version_get_uniform(p_uniform,p_version,p_variant,p_specialization),p_value); }\n\n" ) fd.write( "\t_FORCE_INLINE_ void version_set_uniform(Uniforms p_uniform, int32_t p_value,RID p_version,ShaderVariant p_variant" @@ -497,6 +512,8 @@ def build_gles3_header(filename: str, include: str, class_suffix: str, header_da else: fd.write("\t\tstatic UBOPair *_ubo_pairs=nullptr;\n") + specializations_found = [] + if header_data.specialization_names: fd.write("\t\tstatic Specialization _spec_pairs[]={\n") for i in range(len(header_data.specialization_names)): @@ -507,10 +524,30 @@ def build_gles3_header(filename: str, include: str, class_suffix: str, header_da defval = "false" fd.write('\t\t\t{"' + header_data.specialization_names[i] + '",' + defval + "},\n") + specializations_found.append(header_data.specialization_names[i]) fd.write("\t\t};\n\n") else: fd.write("\t\tstatic Specialization *_spec_pairs=nullptr;\n") + feedback_count = 0 + + if header_data.feedbacks: + + fd.write("\t\tstatic const Feedback _feedbacks[]={\n") + for x in header_data.feedbacks: + name = x[0] + spec = x[1] + if spec in specializations_found: + fd.write('\t\t\t{"' + name + '",' + str(1 << specializations_found.index(spec)) + "},\n") + else: + fd.write('\t\t\t{"' + name + '",0},\n') + + feedback_count += 1 + + fd.write("\t\t};\n\n") + else: + fd.write("\t\tstatic const Feedback* _feedbacks=nullptr;\n") + fd.write("\t\tstatic const char _vertex_code[]={\n") for x in header_data.vertex_lines: for c in x: @@ -535,6 +572,8 @@ def build_gles3_header(filename: str, include: str, class_suffix: str, header_da + ",_uniform_strings," + str(len(header_data.ubos)) + ",_ubo_pairs," + + str(feedback_count) + + ",_feedbacks," + str(len(header_data.texunits)) + ",_texunit_pairs," + str(len(header_data.specialization_names)) |