initial commit, 4.5 stable
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
This commit is contained in:
1
tests/python_build/fixtures/gles3/_included.glsl
Normal file
1
tests/python_build/fixtures/gles3/_included.glsl
Normal file
@@ -0,0 +1 @@
|
||||
#define M_PI 3.14159265359
|
34
tests/python_build/fixtures/gles3/vertex_fragment.glsl
Normal file
34
tests/python_build/fixtures/gles3/vertex_fragment.glsl
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "_included.glsl"
|
||||
|
||||
#[modes]
|
||||
|
||||
mode_ninepatch = #define USE_NINEPATCH
|
||||
/* clang-format off */
|
||||
#[specializations]
|
||||
|
||||
DISABLE_LIGHTING = false
|
||||
|
||||
#[vertex]
|
||||
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
/* clang-format on */
|
||||
layout(location = 0) in highp vec3 vertex;
|
||||
|
||||
out highp vec4 position_interp;
|
||||
|
||||
void main() {
|
||||
position_interp = vec4(vertex.x, 1, 0, 1);
|
||||
}
|
||||
|
||||
#[fragment]
|
||||
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
in highp vec4 position_interp;
|
||||
|
||||
void main() {
|
||||
highp float depth = ((position_interp.z / position_interp.w) + 1.0);
|
||||
frag_color = vec4(depth);
|
||||
}
|
64
tests/python_build/fixtures/gles3/vertex_fragment.out
Normal file
64
tests/python_build/fixtures/gles3/vertex_fragment.out
Normal file
@@ -0,0 +1,64 @@
|
||||
#include "drivers/gles3/shader_gles3.h"
|
||||
|
||||
class VertexFragmentShaderGLES3 : public ShaderGLES3 {
|
||||
public:
|
||||
enum ShaderVariant {
|
||||
MODE_NINEPATCH,
|
||||
};
|
||||
|
||||
enum Specializations {
|
||||
DISABLE_LIGHTING = 1,
|
||||
};
|
||||
|
||||
_FORCE_INLINE_ bool version_bind_shader(RID p_version, ShaderVariant p_variant, uint64_t p_specialization = 0) {
|
||||
return _version_bind_shader(p_version, p_variant, p_specialization);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void _init() override {
|
||||
static const char **_uniform_strings = nullptr;
|
||||
static const char *_variant_defines[] = {
|
||||
"#define USE_NINEPATCH",
|
||||
};
|
||||
static TexUnitPair *_texunit_pairs = nullptr;
|
||||
static UBOPair *_ubo_pairs = nullptr;
|
||||
static Specialization _spec_pairs[] = {
|
||||
{ "DISABLE_LIGHTING", false },
|
||||
};
|
||||
static const Feedback *_feedbacks = nullptr;
|
||||
static const char _vertex_code[] = {
|
||||
R"<!>(
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
/* clang-format on */
|
||||
layout(location = 0) in highp vec3 vertex;
|
||||
|
||||
out highp vec4 position_interp;
|
||||
|
||||
void main() {
|
||||
position_interp = vec4(vertex.x, 1, 0, 1);
|
||||
}
|
||||
|
||||
)<!>"
|
||||
};
|
||||
|
||||
static const char _fragment_code[] = {
|
||||
R"<!>(
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
in highp vec4 position_interp;
|
||||
|
||||
void main() {
|
||||
highp float depth = ((position_interp.z / position_interp.w) + 1.0);
|
||||
frag_color = vec4(depth);
|
||||
}
|
||||
)<!>"
|
||||
};
|
||||
|
||||
_setup(_vertex_code, _fragment_code, "VertexFragmentShaderGLES3",
|
||||
0, _uniform_strings, 0, _ubo_pairs,
|
||||
0, _feedbacks, 0, _texunit_pairs,
|
||||
1, _spec_pairs, 1, _variant_defines);
|
||||
}
|
||||
};
|
1
tests/python_build/fixtures/glsl/_included.glsl
Normal file
1
tests/python_build/fixtures/glsl/_included.glsl
Normal file
@@ -0,0 +1 @@
|
||||
#define M_PI 3.14159265359
|
11
tests/python_build/fixtures/glsl/compute.glsl
Normal file
11
tests/python_build/fixtures/glsl/compute.glsl
Normal file
@@ -0,0 +1,11 @@
|
||||
#[compute]
|
||||
|
||||
#version 450
|
||||
|
||||
#VERSION_DEFINES
|
||||
|
||||
#include "_included.glsl"
|
||||
|
||||
void main() {
|
||||
vec3 static_light = vec3(0, 1, 0);
|
||||
}
|
14
tests/python_build/fixtures/glsl/compute.out
Normal file
14
tests/python_build/fixtures/glsl/compute.out
Normal file
@@ -0,0 +1,14 @@
|
||||
static const char compute_shader_glsl[] = {
|
||||
R"<!>(#[compute]
|
||||
|
||||
#version 450
|
||||
|
||||
#VERSION_DEFINES
|
||||
|
||||
#define M_PI 3.14159265359
|
||||
|
||||
void main() {
|
||||
vec3 static_light = vec3(0, 1, 0);
|
||||
}
|
||||
)<!>"
|
||||
};
|
31
tests/python_build/fixtures/glsl/vertex_fragment.glsl
Normal file
31
tests/python_build/fixtures/glsl/vertex_fragment.glsl
Normal file
@@ -0,0 +1,31 @@
|
||||
#[versions]
|
||||
|
||||
lines = "#define MODE_LINES";
|
||||
|
||||
#[vertex]
|
||||
|
||||
#version 450
|
||||
|
||||
#VERSION_DEFINES
|
||||
|
||||
layout(location = 0) out vec3 uv_interp;
|
||||
|
||||
void main() {
|
||||
#ifdef MODE_LINES
|
||||
uv_interp = vec3(0, 0, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#[fragment]
|
||||
|
||||
#version 450
|
||||
|
||||
#VERSION_DEFINES
|
||||
|
||||
#include "_included.glsl"
|
||||
|
||||
layout(location = 0) out vec4 dst_color;
|
||||
|
||||
void main() {
|
||||
dst_color = vec4(1, 1, 0, 0);
|
||||
}
|
34
tests/python_build/fixtures/glsl/vertex_fragment.out
Normal file
34
tests/python_build/fixtures/glsl/vertex_fragment.out
Normal file
@@ -0,0 +1,34 @@
|
||||
static const char vertex_fragment_shader_glsl[] = {
|
||||
R"<!>(#[versions]
|
||||
|
||||
lines = "#define MODE_LINES";
|
||||
|
||||
#[vertex]
|
||||
|
||||
#version 450
|
||||
|
||||
#VERSION_DEFINES
|
||||
|
||||
layout(location = 0) out vec3 uv_interp;
|
||||
|
||||
void main() {
|
||||
#ifdef MODE_LINES
|
||||
uv_interp = vec3(0, 0, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#[fragment]
|
||||
|
||||
#version 450
|
||||
|
||||
#VERSION_DEFINES
|
||||
|
||||
#define M_PI 3.14159265359
|
||||
|
||||
layout(location = 0) out vec4 dst_color;
|
||||
|
||||
void main() {
|
||||
dst_color = vec4(1, 1, 0, 0);
|
||||
}
|
||||
)<!>"
|
||||
};
|
1
tests/python_build/fixtures/rd_glsl/_included.glsl
Normal file
1
tests/python_build/fixtures/rd_glsl/_included.glsl
Normal file
@@ -0,0 +1 @@
|
||||
#define M_PI 3.14159265359
|
13
tests/python_build/fixtures/rd_glsl/compute.glsl
Normal file
13
tests/python_build/fixtures/rd_glsl/compute.glsl
Normal file
@@ -0,0 +1,13 @@
|
||||
#[compute]
|
||||
|
||||
#version 450
|
||||
|
||||
#VERSION_DEFINES
|
||||
|
||||
#define BLOCK_SIZE 8
|
||||
|
||||
#include "_included.glsl"
|
||||
|
||||
void main() {
|
||||
uint t = BLOCK_SIZE + 1;
|
||||
}
|
25
tests/python_build/fixtures/rd_glsl/compute.out
Normal file
25
tests/python_build/fixtures/rd_glsl/compute.out
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "servers/rendering/renderer_rd/shader_rd.h"
|
||||
|
||||
class ComputeShaderRD : public ShaderRD {
|
||||
public:
|
||||
ComputeShaderRD() {
|
||||
static const char *_vertex_code = nullptr;
|
||||
static const char *_fragment_code = nullptr;
|
||||
static const char _compute_code[] = {
|
||||
R"<!>(
|
||||
#version 450
|
||||
|
||||
#VERSION_DEFINES
|
||||
|
||||
#define BLOCK_SIZE 8
|
||||
|
||||
#define M_PI 3.14159265359
|
||||
|
||||
void main() {
|
||||
uint t = BLOCK_SIZE + 1;
|
||||
}
|
||||
)<!>"
|
||||
};
|
||||
setup(_vertex_code, _fragment_code, _compute_code, "ComputeShaderRD");
|
||||
}
|
||||
};
|
25
tests/python_build/fixtures/rd_glsl/vertex_fragment.glsl
Normal file
25
tests/python_build/fixtures/rd_glsl/vertex_fragment.glsl
Normal file
@@ -0,0 +1,25 @@
|
||||
#[vertex]
|
||||
|
||||
#version 450
|
||||
|
||||
#VERSION_DEFINES
|
||||
|
||||
#include "_included.glsl"
|
||||
|
||||
layout(location = 0) out vec2 uv_interp;
|
||||
|
||||
void main() {
|
||||
uv_interp = vec2(0, 1);
|
||||
}
|
||||
|
||||
#[fragment]
|
||||
|
||||
#version 450
|
||||
|
||||
#VERSION_DEFINES
|
||||
|
||||
layout(location = 0) in vec2 uv_interp;
|
||||
|
||||
void main() {
|
||||
uv_interp = vec2(1, 0);
|
||||
}
|
38
tests/python_build/fixtures/rd_glsl/vertex_fragment.out
Normal file
38
tests/python_build/fixtures/rd_glsl/vertex_fragment.out
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "servers/rendering/renderer_rd/shader_rd.h"
|
||||
|
||||
class VertexFragmentShaderRD : public ShaderRD {
|
||||
public:
|
||||
VertexFragmentShaderRD() {
|
||||
static const char _vertex_code[] = {
|
||||
R"<!>(
|
||||
#version 450
|
||||
|
||||
#VERSION_DEFINES
|
||||
|
||||
#define M_PI 3.14159265359
|
||||
|
||||
layout(location = 0) out vec2 uv_interp;
|
||||
|
||||
void main() {
|
||||
uv_interp = vec2(0, 1);
|
||||
}
|
||||
|
||||
)<!>"
|
||||
};
|
||||
static const char _fragment_code[] = {
|
||||
R"<!>(
|
||||
#version 450
|
||||
|
||||
#VERSION_DEFINES
|
||||
|
||||
layout(location = 0) in vec2 uv_interp;
|
||||
|
||||
void main() {
|
||||
uv_interp = vec2(1, 0);
|
||||
}
|
||||
)<!>"
|
||||
};
|
||||
static const char *_compute_code = nullptr;
|
||||
setup(_vertex_code, _fragment_code, _compute_code, "VertexFragmentShaderRD");
|
||||
}
|
||||
};
|
63
tests/python_build/validate_builders.py
Normal file
63
tests/python_build/validate_builders.py
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
if __name__ != "__main__":
|
||||
raise ImportError(f"{__name__} should not be used as a module.")
|
||||
|
||||
import os
|
||||
import sys
|
||||
from typing import Any, Callable
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../"))
|
||||
|
||||
from gles3_builders import build_gles3_header
|
||||
from glsl_builders import build_raw_header, build_rd_header
|
||||
|
||||
FUNC_PATH_KWARGS: list[tuple[Callable[..., None], str, dict[str, Any]]] = [
|
||||
(
|
||||
build_gles3_header,
|
||||
"tests/python_build/fixtures/gles3/vertex_fragment.out",
|
||||
{"shader": "tests/python_build/fixtures/gles3/vertex_fragment.glsl"},
|
||||
),
|
||||
(
|
||||
build_raw_header,
|
||||
"tests/python_build/fixtures/glsl/compute.out",
|
||||
{"shader": "tests/python_build/fixtures/glsl/compute.glsl"},
|
||||
),
|
||||
(
|
||||
build_raw_header,
|
||||
"tests/python_build/fixtures/glsl/vertex_fragment.out",
|
||||
{"shader": "tests/python_build/fixtures/glsl/vertex_fragment.glsl"},
|
||||
),
|
||||
(
|
||||
build_rd_header,
|
||||
"tests/python_build/fixtures/rd_glsl/compute.out",
|
||||
{"shader": "tests/python_build/fixtures/rd_glsl/compute.glsl"},
|
||||
),
|
||||
(
|
||||
build_rd_header,
|
||||
"tests/python_build/fixtures/rd_glsl/vertex_fragment.out",
|
||||
{"shader": "tests/python_build/fixtures/rd_glsl/vertex_fragment.glsl"},
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def main() -> int:
|
||||
ret = 0
|
||||
|
||||
for func, path, kwargs in FUNC_PATH_KWARGS:
|
||||
if os.path.exists(out_path := os.path.abspath(path)):
|
||||
with open(out_path, "rb") as file:
|
||||
raw = file.read()
|
||||
func(path, **kwargs)
|
||||
with open(out_path, "rb") as file:
|
||||
if raw != file.read():
|
||||
ret += 1
|
||||
else:
|
||||
func(path, **kwargs)
|
||||
ret += 1
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
sys.exit(main())
|
Reference in New Issue
Block a user