Skip to content

Commit 48305ba

Browse files
committed
Add python build.
1 parent f4bc581 commit 48305ba

21 files changed

+450
-0
lines changed

tests/python_build/conftest.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import os
2+
import sys
3+
from pathlib import Path
4+
5+
import pytest
6+
7+
CWD = Path(__file__).parent
8+
ROOT = CWD.parent.parent
9+
# append directory with build files to sys.path to import them
10+
sys.path.append(str(ROOT))
11+
12+
13+
@pytest.fixture
14+
def shader_files(request):
15+
shader_path = request.param
16+
17+
res = {
18+
"path_input": str(CWD / "fixtures" / f"{shader_path}.glsl"),
19+
"path_output": str(CWD / "fixtures" / f"{shader_path}.glsl.gen.h"),
20+
"path_expected_full": str(CWD / "fixtures" / f"{shader_path}_expected_full.glsl"),
21+
"path_expected_parts": str(CWD / "fixtures" / f"{shader_path}_expected_parts.json"),
22+
}
23+
yield res
24+
25+
if not os.getenv("PYTEST_KEEP_GENERATED_FILES"):
26+
os.remove(res["path_output"])
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#define M_PI 3.14159265359
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include "_included.glsl"
2+
3+
#[modes]
4+
5+
mode_ninepatch = #define USE_NINEPATCH
6+
7+
#[specializations]
8+
9+
DISABLE_LIGHTING = false
10+
11+
#[vertex]
12+
13+
precision highp float;
14+
precision highp int;
15+
16+
layout(location = 0) in highp vec3 vertex;
17+
18+
out highp vec4 position_interp;
19+
20+
void main() {
21+
position_interp = vec4(vertex.x,1,0,1);
22+
}
23+
24+
#[fragment]
25+
26+
precision highp float;
27+
precision highp int;
28+
29+
in highp vec4 position_interp;
30+
31+
void main() {
32+
highp float depth = ((position_interp.z / position_interp.w) + 1.0);
33+
frag_color = vec4(depth);
34+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/* WARNING, THIS FILE WAS GENERATED, DO NOT EDIT */
2+
#ifndef VERTEX_FRAGMENT_GLSL_GEN_HGLES3_GLES3
3+
#define VERTEX_FRAGMENT_GLSL_GEN_HGLES3_GLES3
4+
5+
6+
#include "drivers/gles3/shader_gles3.h"
7+
8+
9+
class VertexFragmentShaderGLES3 : public ShaderGLES3 {
10+
11+
public:
12+
13+
enum ShaderVariant {
14+
MODE_NINEPATCH,
15+
};
16+
17+
enum Specializations {
18+
DISABLE_LIGHTING=1,
19+
};
20+
21+
_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); }
22+
23+
protected:
24+
25+
virtual void _init() override {
26+
27+
static const char **_uniform_strings=nullptr;
28+
static const char* _variant_defines[]={
29+
"#define USE_NINEPATCH",
30+
};
31+
32+
static TexUnitPair *_texunit_pairs=nullptr;
33+
static UBOPair *_ubo_pairs=nullptr;
34+
static Specialization _spec_pairs[]={
35+
{"DISABLE_LIGHTING",false},
36+
};
37+
38+
static const Feedback* _feedbacks=nullptr;
39+
static const char _vertex_code[]={
40+
10,112,114,101,99,105,115,105,111,110,32,104,105,103,104,112,32,102,108,111,97,116,59,10,112,114,101,99,105,115,105,111,110,32,104,105,103,104,112,32,105,110,116,59,10,10,108,97,121,111,117,116,40,108,111,99,97,116,105,111,110,32,61,32,48,41,32,105,110,32,104,105,103,104,112,32,118,101,99,51,32,118,101,114,116,101,120,59,10,10,111,117,116,32,104,105,103,104,112,32,118,101,99,52,32,112,111,115,105,116,105,111,110,95,105,110,116,101,114,112,59,10,10,118,111,105,100,32,109,97,105,110,40,41,32,123,10,9,112,111,115,105,116,105,111,110,95,105,110,116,101,114,112,32,61,32,118,101,99,52,40,118,101,114,116,101,120,46,120,44,49,44,48,44,49,41,59,10,125,10,10, 0};
41+
42+
static const char _fragment_code[]={
43+
10,112,114,101,99,105,115,105,111,110,32,104,105,103,104,112,32,102,108,111,97,116,59,10,112,114,101,99,105,115,105,111,110,32,104,105,103,104,112,32,105,110,116,59,10,10,105,110,32,104,105,103,104,112,32,118,101,99,52,32,112,111,115,105,116,105,111,110,95,105,110,116,101,114,112,59,10,10,118,111,105,100,32,109,97,105,110,40,41,32,123,10,9,104,105,103,104,112,32,102,108,111,97,116,32,100,101,112,116,104,32,61,32,40,40,112,111,115,105,116,105,111,110,95,105,110,116,101,114,112,46,122,32,47,32,112,111,115,105,116,105,111,110,95,105,110,116,101,114,112,46,119,41,32,43,32,49,46,48,41,59,10,9,102,114,97,103,95,99,111,108,111,114,32,61,32,118,101,99,52,40,100,101,112,116,104,41,59,10,125,10, 0};
44+
45+
_setup(_vertex_code,_fragment_code,"VertexFragmentShaderGLES3",0,_uniform_strings,0,_ubo_pairs,0,_feedbacks,0,_texunit_pairs,1,_spec_pairs,1,_variant_defines);
46+
}
47+
48+
};
49+
50+
#endif
51+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"vertex_lines": [
3+
"",
4+
"precision highp float;",
5+
"precision highp int;",
6+
"",
7+
"layout(location = 0) in highp vec3 vertex;",
8+
"",
9+
"out highp vec4 position_interp;",
10+
"",
11+
"void main() {",
12+
"\tposition_interp = vec4(vertex.x,1,0,1);",
13+
"}",
14+
""
15+
],
16+
"fragment_lines": [
17+
"",
18+
"precision highp float;",
19+
"precision highp int;",
20+
"",
21+
"in highp vec4 position_interp;",
22+
"",
23+
"void main() {",
24+
"\thighp float depth = ((position_interp.z / position_interp.w) + 1.0);",
25+
"\tfrag_color = vec4(depth);",
26+
"}"
27+
],
28+
"uniforms": [],
29+
"fbos": [],
30+
"texunits": [],
31+
"texunit_names": [],
32+
"ubos": [],
33+
"ubo_names": [],
34+
"feedbacks": [],
35+
"vertex_included_files": [],
36+
"fragment_included_files": [],
37+
"reading": "fragment",
38+
"line_offset": 33,
39+
"vertex_offset": 10,
40+
"fragment_offset": 23,
41+
"variant_defines": [
42+
"#define USE_NINEPATCH"
43+
],
44+
"variant_names": [
45+
"MODE_NINEPATCH"
46+
],
47+
"specialization_names": [
48+
"DISABLE_LIGHTING"
49+
],
50+
"specialization_values": [
51+
" false\n"
52+
]
53+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#define M_PI 3.14159265359
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#[compute]
2+
3+
#version 450
4+
5+
#VERSION_DEFINES
6+
7+
8+
#include "_included.glsl"
9+
10+
void main() {
11+
vec3 static_light = vec3(0, 1, 0);
12+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* WARNING, THIS FILE WAS GENERATED, DO NOT EDIT */
2+
#ifndef COMPUTE_SHADER_GLSL_RAW_H
3+
#define COMPUTE_SHADER_GLSL_RAW_H
4+
5+
static const char compute_shader_glsl[] = {
6+
35,91,99,111,109,112,117,116,101,93,10,10,35,118,101,114,115,105,111,110,32,52,53,48,10,10,35,86,69,82,83,73,79,78,95,68,69,70,73,78,69,83,10,10,10,35,100,101,102,105,110,101,32,77,95,80,73,32,51,46,49,52,49,53,57,50,54,53,51,53,57,10,10,118,111,105,100,32,109,97,105,110,40,41,32,123,10,9,118,101,99,51,32,115,116,97,116,105,99,95,108,105,103,104,116,32,61,32,118,101,99,51,40,48,44,32,49,44,32,48,41,59,10,125,10,0
7+
};
8+
#endif
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"code": "#[compute]\n\n#version 450\n\n#VERSION_DEFINES\n\n\n#define M_PI 3.14159265359\n\nvoid main() {\n\tvec3 static_light = vec3(0, 1, 0);\n}\n"
3+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#[versions]
2+
3+
lines = "#define MODE_LINES";
4+
5+
#[vertex]
6+
7+
#version 450
8+
9+
#VERSION_DEFINES
10+
11+
layout(location = 0) out vec3 uv_interp;
12+
13+
void main() {
14+
15+
#ifdef MODE_LINES
16+
uv_interp = vec3(0,0,1);
17+
#endif
18+
}
19+
20+
#[fragment]
21+
22+
#version 450
23+
24+
#VERSION_DEFINES
25+
26+
#include "_included.glsl"
27+
28+
layout(location = 0) out vec4 dst_color;
29+
30+
void main() {
31+
dst_color = vec4(1,1,0,0);
32+
}

0 commit comments

Comments
 (0)