Preparing for adding an engine library.
This commit is contained in:
parent
f4723ca722
commit
b8ec0ec5c1
@ -5,17 +5,42 @@
|
|||||||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||||
|
|
||||||
Cmdline:
|
Cmdline:
|
||||||
sokol-shdc -i ./samples/triangle-sapp.glsl -o F:\dev\luajit\Thunc\sokol-luajit\bin/shaderbin/shader_gen.h -l glsl410 -f sokol
|
sokol-shdc -i ./samples/offscreen-sapp.glsl -o F:\dev\luajit\Thunc\sokol-luajit\bin/shaderbin/shader_gen.h -l glsl410 -f sokol
|
||||||
|
|
||||||
Overview:
|
Overview:
|
||||||
=========
|
=========
|
||||||
Shader program: 'triangle':
|
Shader program: 'default':
|
||||||
Get shader desc: triangle_shader_desc(sg_query_backend());
|
Get shader desc: default_shader_desc(sg_query_backend());
|
||||||
Vertex shader: vs
|
Vertex shader: vs_default
|
||||||
Attributes:
|
Attributes:
|
||||||
ATTR_vs_position => 0
|
ATTR_vs_default_position => 0
|
||||||
ATTR_vs_color0 => 1
|
ATTR_vs_default_normal => 1
|
||||||
Fragment shader: fs
|
ATTR_vs_default_texcoord0 => 2
|
||||||
|
Uniform block 'vs_params':
|
||||||
|
C struct: vs_params_t
|
||||||
|
Bind slot: SLOT_vs_params => 0
|
||||||
|
Fragment shader: fs_default
|
||||||
|
Image 'tex':
|
||||||
|
Image type: SG_IMAGETYPE_2D
|
||||||
|
Sample type: SG_IMAGESAMPLETYPE_FLOAT
|
||||||
|
Multisampled: false
|
||||||
|
Bind slot: SLOT_tex => 0
|
||||||
|
Sampler 'smp':
|
||||||
|
Type: SG_SAMPLERTYPE_FILTERING
|
||||||
|
Bind slot: SLOT_smp => 0
|
||||||
|
Image Sampler Pair 'tex_smp':
|
||||||
|
Image: tex
|
||||||
|
Sampler: smp
|
||||||
|
Shader program: 'offscreen':
|
||||||
|
Get shader desc: offscreen_shader_desc(sg_query_backend());
|
||||||
|
Vertex shader: vs_offscreen
|
||||||
|
Attributes:
|
||||||
|
ATTR_vs_offscreen_position => 0
|
||||||
|
ATTR_vs_offscreen_normal => 1
|
||||||
|
Uniform block 'vs_params':
|
||||||
|
C struct: vs_params_t
|
||||||
|
Bind slot: SLOT_vs_params => 0
|
||||||
|
Fragment shader: fs_offscreen
|
||||||
*/
|
*/
|
||||||
#if !defined(SOKOL_GFX_INCLUDED)
|
#if !defined(SOKOL_GFX_INCLUDED)
|
||||||
#error "Please include sokol_gfx.h before shader_gen.h"
|
#error "Please include sokol_gfx.h before shader_gen.h"
|
||||||
@ -27,73 +52,219 @@
|
|||||||
#define SOKOL_SHDC_ALIGN(a) __attribute__((aligned(a)))
|
#define SOKOL_SHDC_ALIGN(a) __attribute__((aligned(a)))
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#define ATTR_vs_position (0)
|
#define ATTR_vs_default_position (0)
|
||||||
#define ATTR_vs_color0 (1)
|
#define ATTR_vs_default_normal (1)
|
||||||
|
#define ATTR_vs_default_texcoord0 (2)
|
||||||
|
#define ATTR_vs_offscreen_position (0)
|
||||||
|
#define ATTR_vs_offscreen_normal (1)
|
||||||
|
#define SLOT_vs_params (0)
|
||||||
|
#define SLOT_tex (0)
|
||||||
|
#define SLOT_smp (0)
|
||||||
|
#pragma pack(push,1)
|
||||||
|
SOKOL_SHDC_ALIGN(16) typedef struct vs_params_t {
|
||||||
|
hmm_mat4 mvp;
|
||||||
|
} vs_params_t;
|
||||||
|
#pragma pack(pop)
|
||||||
/*
|
/*
|
||||||
#version 410
|
#version 410
|
||||||
|
|
||||||
|
uniform vec4 vs_params[4];
|
||||||
layout(location = 0) in vec4 position;
|
layout(location = 0) in vec4 position;
|
||||||
layout(location = 0) out vec4 color;
|
layout(location = 0) out vec4 nrm;
|
||||||
layout(location = 1) in vec4 color0;
|
layout(location = 1) in vec4 normal;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = position;
|
gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * position;
|
||||||
color = color0;
|
nrm = normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static const uint8_t vs_source_glsl410[194] = {
|
static const uint8_t vs_offscreen_source_glsl410[280] = {
|
||||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x31,0x30,0x0a,0x0a,0x6c,0x61,
|
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x31,0x30,0x0a,0x0a,0x75,0x6e,
|
||||||
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,0x5f,0x70,0x61,
|
||||||
0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,
|
0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,
|
||||||
0x69,0x6f,0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
|
0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,
|
||||||
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,
|
0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,
|
||||||
0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,
|
0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,
|
||||||
0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,
|
0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x6e,0x72,
|
||||||
0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a,
|
0x6d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,
|
||||||
0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,
|
0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,
|
||||||
0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,
|
||||||
0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,
|
0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,
|
||||||
0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,0x0a,
|
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x73,
|
||||||
0x0a,0x00,
|
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,
|
||||||
|
0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,
|
||||||
|
0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
|
||||||
|
0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
|
||||||
|
0x3b,0x0a,0x20,0x20,0x20,0x20,0x6e,0x72,0x6d,0x20,0x3d,0x20,0x6e,0x6f,0x72,0x6d,
|
||||||
|
0x61,0x6c,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
#version 410
|
#version 410
|
||||||
|
|
||||||
layout(location = 0) out vec4 frag_color;
|
layout(location = 0) out vec4 frag_color;
|
||||||
layout(location = 0) in vec4 color;
|
layout(location = 0) in vec4 nrm;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
frag_color = color;
|
frag_color = vec4((nrm.xyz * 0.5) + vec3(0.5), 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static const uint8_t fs_source_glsl410[135] = {
|
static const uint8_t fs_offscreen_source_glsl410[166] = {
|
||||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x31,0x30,0x0a,0x0a,0x6c,0x61,
|
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x31,0x30,0x0a,0x0a,0x6c,0x61,
|
||||||
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||||
0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,
|
0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,
|
||||||
0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,
|
0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,
|
||||||
0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,
|
0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,
|
||||||
0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,
|
0x76,0x65,0x63,0x34,0x20,0x6e,0x72,0x6d,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,
|
||||||
0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,
|
||||||
0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,
|
0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x28,
|
||||||
0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
0x6e,0x72,0x6d,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x30,0x2e,0x35,0x29,0x20,0x2b,
|
||||||
|
0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x35,0x29,0x2c,0x20,0x31,0x2e,0x30,0x29,
|
||||||
|
0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||||
};
|
};
|
||||||
static inline const sg_shader_desc* triangle_shader_desc(sg_backend backend) {
|
/*
|
||||||
|
#version 410
|
||||||
|
|
||||||
|
uniform vec4 vs_params[4];
|
||||||
|
layout(location = 0) in vec4 position;
|
||||||
|
layout(location = 1) out vec2 uv;
|
||||||
|
layout(location = 2) in vec2 texcoord0;
|
||||||
|
layout(location = 0) out vec4 nrm;
|
||||||
|
layout(location = 1) in vec4 normal;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
mat4 _22 = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]);
|
||||||
|
gl_Position = _22 * position;
|
||||||
|
uv = texcoord0;
|
||||||
|
nrm = _22 * normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
static const uint8_t vs_default_source_glsl410[400] = {
|
||||||
|
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x31,0x30,0x0a,0x0a,0x75,0x6e,
|
||||||
|
0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,0x5f,0x70,0x61,
|
||||||
|
0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,
|
||||||
|
0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,
|
||||||
|
0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,
|
||||||
|
0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,
|
||||||
|
0x3d,0x20,0x31,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,
|
||||||
|
0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,
|
||||||
|
0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74,
|
||||||
|
0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,
|
||||||
|
0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,
|
||||||
|
0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x6e,0x72,0x6d,0x3b,0x0a,0x6c,0x61,0x79,
|
||||||
|
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,
|
||||||
|
0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
|
||||||
|
0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,
|
||||||
|
0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x74,0x34,0x20,0x5f,0x32,0x32,0x20,0x3d,0x20,
|
||||||
|
0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,
|
||||||
|
0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,
|
||||||
|
0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x76,
|
||||||
|
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x3b,0x0a,0x20,0x20,
|
||||||
|
0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||||
|
0x5f,0x32,0x32,0x20,0x2a,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,
|
||||||
|
0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,
|
||||||
|
0x64,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6e,0x72,0x6d,0x20,0x3d,0x20,0x5f,0x32,
|
||||||
|
0x32,0x20,0x2a,0x20,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||||
|
|
||||||
|
};
|
||||||
|
/*
|
||||||
|
#version 410
|
||||||
|
|
||||||
|
uniform sampler2D tex_smp;
|
||||||
|
|
||||||
|
layout(location = 1) in vec2 uv;
|
||||||
|
layout(location = 0) in vec4 nrm;
|
||||||
|
layout(location = 0) out vec4 frag_color;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
frag_color = vec4(texture(tex_smp, uv * vec2(20.0, 10.0)).xyz * fma(clamp(dot(nrm.xyz, vec3(0.57735025882720947265625, 0.57735025882720947265625, -0.57735025882720947265625)), 0.0, 1.0), 2.0, 0.25), 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
static const uint8_t fs_default_source_glsl410[379] = {
|
||||||
|
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x31,0x30,0x0a,0x0a,0x75,0x6e,
|
||||||
|
0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,
|
||||||
|
0x74,0x65,0x78,0x5f,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,
|
||||||
|
0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,
|
||||||
|
0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,
|
||||||
|
0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,
|
||||||
|
0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x6e,0x72,0x6d,0x3b,0x0a,0x6c,0x61,0x79,
|
||||||
|
0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,
|
||||||
|
0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,
|
||||||
|
0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,
|
||||||
|
0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,
|
||||||
|
0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x74,0x65,0x78,0x74,
|
||||||
|
0x75,0x72,0x65,0x28,0x74,0x65,0x78,0x5f,0x73,0x6d,0x70,0x2c,0x20,0x75,0x76,0x20,
|
||||||
|
0x2a,0x20,0x76,0x65,0x63,0x32,0x28,0x32,0x30,0x2e,0x30,0x2c,0x20,0x31,0x30,0x2e,
|
||||||
|
0x30,0x29,0x29,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x66,0x6d,0x61,0x28,0x63,0x6c,
|
||||||
|
0x61,0x6d,0x70,0x28,0x64,0x6f,0x74,0x28,0x6e,0x72,0x6d,0x2e,0x78,0x79,0x7a,0x2c,
|
||||||
|
0x20,0x76,0x65,0x63,0x33,0x28,0x30,0x2e,0x35,0x37,0x37,0x33,0x35,0x30,0x32,0x35,
|
||||||
|
0x38,0x38,0x32,0x37,0x32,0x30,0x39,0x34,0x37,0x32,0x36,0x35,0x36,0x32,0x35,0x2c,
|
||||||
|
0x20,0x30,0x2e,0x35,0x37,0x37,0x33,0x35,0x30,0x32,0x35,0x38,0x38,0x32,0x37,0x32,
|
||||||
|
0x30,0x39,0x34,0x37,0x32,0x36,0x35,0x36,0x32,0x35,0x2c,0x20,0x2d,0x30,0x2e,0x35,
|
||||||
|
0x37,0x37,0x33,0x35,0x30,0x32,0x35,0x38,0x38,0x32,0x37,0x32,0x30,0x39,0x34,0x37,
|
||||||
|
0x32,0x36,0x35,0x36,0x32,0x35,0x29,0x29,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,
|
||||||
|
0x2e,0x30,0x29,0x2c,0x20,0x32,0x2e,0x30,0x2c,0x20,0x30,0x2e,0x32,0x35,0x29,0x2c,
|
||||||
|
0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||||
|
};
|
||||||
|
static inline const sg_shader_desc* default_shader_desc(sg_backend backend) {
|
||||||
if (backend == SG_BACKEND_GLCORE) {
|
if (backend == SG_BACKEND_GLCORE) {
|
||||||
static sg_shader_desc desc;
|
static sg_shader_desc desc;
|
||||||
static bool valid;
|
static bool valid;
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
valid = true;
|
valid = true;
|
||||||
desc.attrs[0].name = "position";
|
desc.attrs[0].name = "position";
|
||||||
desc.attrs[1].name = "color0";
|
desc.attrs[1].name = "normal";
|
||||||
desc.vs.source = (const char*)vs_source_glsl410;
|
desc.attrs[2].name = "texcoord0";
|
||||||
|
desc.vs.source = (const char*)vs_default_source_glsl410;
|
||||||
desc.vs.entry = "main";
|
desc.vs.entry = "main";
|
||||||
desc.fs.source = (const char*)fs_source_glsl410;
|
desc.vs.uniform_blocks[0].size = 64;
|
||||||
|
desc.vs.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
|
||||||
|
desc.vs.uniform_blocks[0].uniforms[0].name = "vs_params";
|
||||||
|
desc.vs.uniform_blocks[0].uniforms[0].type = SG_UNIFORMTYPE_FLOAT4;
|
||||||
|
desc.vs.uniform_blocks[0].uniforms[0].array_count = 4;
|
||||||
|
desc.fs.source = (const char*)fs_default_source_glsl410;
|
||||||
desc.fs.entry = "main";
|
desc.fs.entry = "main";
|
||||||
desc.label = "triangle_shader";
|
desc.fs.images[0].used = true;
|
||||||
|
desc.fs.images[0].multisampled = false;
|
||||||
|
desc.fs.images[0].image_type = SG_IMAGETYPE_2D;
|
||||||
|
desc.fs.images[0].sample_type = SG_IMAGESAMPLETYPE_FLOAT;
|
||||||
|
desc.fs.samplers[0].used = true;
|
||||||
|
desc.fs.samplers[0].sampler_type = SG_SAMPLERTYPE_FILTERING;
|
||||||
|
desc.fs.image_sampler_pairs[0].used = true;
|
||||||
|
desc.fs.image_sampler_pairs[0].image_slot = 0;
|
||||||
|
desc.fs.image_sampler_pairs[0].sampler_slot = 0;
|
||||||
|
desc.fs.image_sampler_pairs[0].glsl_name = "tex_smp";
|
||||||
|
desc.label = "default_shader";
|
||||||
|
}
|
||||||
|
return &desc;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static inline const sg_shader_desc* offscreen_shader_desc(sg_backend backend) {
|
||||||
|
if (backend == SG_BACKEND_GLCORE) {
|
||||||
|
static sg_shader_desc desc;
|
||||||
|
static bool valid;
|
||||||
|
if (!valid) {
|
||||||
|
valid = true;
|
||||||
|
desc.attrs[0].name = "position";
|
||||||
|
desc.attrs[1].name = "normal";
|
||||||
|
desc.vs.source = (const char*)vs_offscreen_source_glsl410;
|
||||||
|
desc.vs.entry = "main";
|
||||||
|
desc.vs.uniform_blocks[0].size = 64;
|
||||||
|
desc.vs.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
|
||||||
|
desc.vs.uniform_blocks[0].uniforms[0].name = "vs_params";
|
||||||
|
desc.vs.uniform_blocks[0].uniforms[0].type = SG_UNIFORMTYPE_FLOAT4;
|
||||||
|
desc.vs.uniform_blocks[0].uniforms[0].array_count = 4;
|
||||||
|
desc.fs.source = (const char*)fs_offscreen_source_glsl410;
|
||||||
|
desc.fs.entry = "main";
|
||||||
|
desc.label = "offscreen_shader";
|
||||||
}
|
}
|
||||||
return &desc;
|
return &desc;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package.path = package.path..";../../?.lua"
|
package.path = package.path..";../?.lua"
|
||||||
local dirtools = require("tools.dirtools")
|
local dirtools = require("tools.dirtools")
|
||||||
local base_path = dirtools.get_app_path("sokol%-luajit")
|
local base_path = dirtools.get_app_path("sokol%-luajit")
|
||||||
|
|
||||||
|
|||||||
@ -1,27 +1,10 @@
|
|||||||
-- A way to run the tool as part of a runtime or a build stage.
|
-- A way to run the tool as part of a runtime or a build stage.
|
||||||
local ffi = require("ffi")
|
local ffi = require("ffi")
|
||||||
local sg = require("sokol_gfx")
|
local sg = sg or require("sokol_gfx")
|
||||||
local dirtools = require("tools.dirtools")
|
local dirtools = require("tools.dirtools")
|
||||||
|
|
||||||
-- local base_dir = "."
|
local base_dir = nil
|
||||||
-- if(ffi.os == "Windows") then
|
local tools_dir = nil
|
||||||
-- local cmdh = io.popen("cd", "r")
|
|
||||||
-- if(cmdh) then base_dir = cmdh:read("*a"); cmdh:close() end
|
|
||||||
-- else
|
|
||||||
-- local cmdh = io.popen("cwd", "r")
|
|
||||||
-- if(cmdh) then base_dir = cmdh:read("*a"); cmdh:close() end
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- local folder_name = "sokol%-luajit"
|
|
||||||
-- local last_folder, remain = string.match(base_dir, "(.-"..folder_name..")(.-)")
|
|
||||||
-- remain = remain:gsub("%s+", "")
|
|
||||||
-- if(ffi.os == "Windows") then
|
|
||||||
-- base_dir = last_folder.."\\"
|
|
||||||
-- else
|
|
||||||
-- base_dir = last_folder.."/"
|
|
||||||
-- end
|
|
||||||
-- print("Base Directory: "..base_dir)
|
|
||||||
local base_dir = dirtools.get_app_path("sokol%-luajit")
|
|
||||||
|
|
||||||
-- Setup some defaults
|
-- Setup some defaults
|
||||||
local sh_compiler = {}
|
local sh_compiler = {}
|
||||||
@ -32,8 +15,13 @@ local exec = nil
|
|||||||
-- Set the base path from where you are running your app from
|
-- Set the base path from where you are running your app from
|
||||||
-- returns a lua table that can then be used in the soko shader methods
|
-- returns a lua table that can then be used in the soko shader methods
|
||||||
-- --------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------
|
||||||
sh_compiler.init = function(base_path, debug_shader)
|
sh_compiler.init = function(base_path, debug_shader, tools_path)
|
||||||
|
|
||||||
base_dir = dirtools.get_app_path(base_path)
|
base_dir = dirtools.get_app_path(base_path)
|
||||||
|
tools_dir = base_dir
|
||||||
|
if(tools_path) then
|
||||||
|
tools_dir = base_dir..tools_path.."/"
|
||||||
|
end
|
||||||
|
|
||||||
sh_compiler.target_tmp = base_dir.."bin/shaderbin/shader_gen.h"
|
sh_compiler.target_tmp = base_dir.."bin/shaderbin/shader_gen.h"
|
||||||
sh_compiler.target_lang = "glsl410"
|
sh_compiler.target_lang = "glsl410"
|
||||||
@ -41,12 +29,12 @@ sh_compiler.init = function(base_path, debug_shader)
|
|||||||
|
|
||||||
sh_compiler.typedefs = {}
|
sh_compiler.typedefs = {}
|
||||||
|
|
||||||
sh_compiler.debug = debug_shader
|
sh_compiler.debug = debug_shader or false
|
||||||
|
|
||||||
exec_opts = {
|
exec_opts = {
|
||||||
["Linx"] = base_dir.."tools/shader_compiler/linux/sokol-shdc.exe",
|
["Linx"] = tools_dir.."tools/shader_compiler/linux/sokol-shdc.exe",
|
||||||
["Windows"] = base_dir.."tools\\shader_compiler\\win32\\sokol-shdc.exe",
|
["Windows"] = tools_dir.."tools\\shader_compiler\\win32\\sokol-shdc.exe",
|
||||||
["MacOSX"] = base_dir.."tools/shader_compiler/win32/sokol-shdc.exe",
|
["MacOSX"] = tools_dir.."tools/shader_compiler/win32/sokol-shdc.exe",
|
||||||
}
|
}
|
||||||
exec = exec_opts[ffi.os]
|
exec = exec_opts[ffi.os]
|
||||||
return sh_compiler
|
return sh_compiler
|
||||||
@ -171,4 +159,8 @@ sh_compiler.compile = function( glslfile, program_name )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return sh_compiler
|
return sh_compiler
|
||||||
|
|
||||||
|
-- --------------------------------------------------------------------------------------
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user