No more WebGPU errors
This commit is contained in:
parent
ceaa78ea1a
commit
0059d8fc3b
|
|
@ -20,6 +20,7 @@
|
||||||
"ratio": "cpp",
|
"ratio": "cpp",
|
||||||
"sokol_log.h": "c",
|
"sokol_log.h": "c",
|
||||||
"syslog.h": "c",
|
"syslog.h": "c",
|
||||||
"base.h": "c"
|
"base.h": "c",
|
||||||
|
"stdarg.h": "c"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -311,7 +311,7 @@ static const uint8_t vs_source_wgsl[1944] = {
|
||||||
struct main_out {
|
struct main_out {
|
||||||
@builtin(frag_depth)
|
@builtin(frag_depth)
|
||||||
gl_FragDepth_1 : f32,
|
gl_FragDepth_1 : f32,
|
||||||
@location(4)
|
@location(0)
|
||||||
frag_color_1 : vec4f,
|
frag_color_1 : vec4f,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -371,7 +371,7 @@ static const uint8_t fs_source_wgsl[1047] = {
|
||||||
0x69,0x6c,0x74,0x69,0x6e,0x28,0x66,0x72,0x61,0x67,0x5f,0x64,0x65,0x70,0x74,0x68,
|
0x69,0x6c,0x74,0x69,0x6e,0x28,0x66,0x72,0x61,0x67,0x5f,0x64,0x65,0x70,0x74,0x68,
|
||||||
0x29,0x0a,0x20,0x20,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67,0x44,0x65,0x70,0x74,0x68,
|
0x29,0x0a,0x20,0x20,0x67,0x6c,0x5f,0x46,0x72,0x61,0x67,0x44,0x65,0x70,0x74,0x68,
|
||||||
0x5f,0x31,0x20,0x3a,0x20,0x66,0x33,0x32,0x2c,0x0a,0x20,0x20,0x40,0x6c,0x6f,0x63,
|
0x5f,0x31,0x20,0x3a,0x20,0x66,0x33,0x32,0x2c,0x0a,0x20,0x20,0x40,0x6c,0x6f,0x63,
|
||||||
0x61,0x74,0x69,0x6f,0x6e,0x28,0x34,0x29,0x0a,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,
|
0x61,0x74,0x69,0x6f,0x6e,0x28,0x30,0x29,0x0a,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,
|
||||||
0x63,0x6f,0x6c,0x6f,0x72,0x5f,0x31,0x20,0x3a,0x20,0x76,0x65,0x63,0x34,0x66,0x2c,
|
0x63,0x6f,0x6c,0x6f,0x72,0x5f,0x31,0x20,0x3a,0x20,0x76,0x65,0x63,0x34,0x66,0x2c,
|
||||||
0x0a,0x7d,0x0a,0x0a,0x40,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x0a,0x66,0x6e,
|
0x0a,0x7d,0x0a,0x0a,0x40,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x0a,0x66,0x6e,
|
||||||
0x20,0x6d,0x61,0x69,0x6e,0x28,0x40,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x28,
|
0x20,0x6d,0x61,0x69,0x6e,0x28,0x40,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x28,
|
||||||
|
|
|
||||||
32
src/main.c
32
src/main.c
|
|
@ -13,7 +13,9 @@
|
||||||
|
|
||||||
#include "generated/base.h"
|
#include "generated/base.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#ifndef _STDIO_H
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
@ -44,8 +46,9 @@ typedef struct position_t
|
||||||
typedef struct renderer_t {
|
typedef struct renderer_t {
|
||||||
sg_pipeline pipeline;
|
sg_pipeline pipeline;
|
||||||
sg_pipeline compute;
|
sg_pipeline compute;
|
||||||
sg_bindings* binding;
|
sg_bindings binding;
|
||||||
sg_range uniform;
|
sg_range uniform;
|
||||||
|
sg_pass_action pass;
|
||||||
} renderer_t;
|
} renderer_t;
|
||||||
|
|
||||||
typedef struct userdata_t
|
typedef struct userdata_t
|
||||||
|
|
@ -60,17 +63,14 @@ static void frame(void* _userdata)
|
||||||
{
|
{
|
||||||
userdata_t* userdata = (userdata_t*) _userdata;
|
userdata_t* userdata = (userdata_t*) _userdata;
|
||||||
|
|
||||||
sg_begin_pass(&(sg_pass) {
|
sg_begin_pass(&(sg_pass){
|
||||||
.action = {
|
.action = userdata->renderer.pass,
|
||||||
.colors[0] = {
|
|
||||||
.load_action = SG_LOADACTION_CLEAR,
|
|
||||||
.clear_value = { 0.0f, 0.0f, 0.0f, 1.0f},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
.swapchain = sglue_swapchain(),
|
.swapchain = sglue_swapchain(),
|
||||||
});
|
});
|
||||||
|
|
||||||
sg_apply_pipeline(userdata->renderer.pipeline);
|
sg_apply_pipeline(userdata->renderer.pipeline);
|
||||||
sg_apply_bindings(userdata->renderer.binding);
|
sg_apply_bindings(&userdata->renderer.binding);
|
||||||
|
|
||||||
sg_apply_uniforms(UB_vs_uniform, &userdata->renderer.uniform);
|
sg_apply_uniforms(UB_vs_uniform, &userdata->renderer.uniform);
|
||||||
sg_apply_uniforms(UB_fs_uniform, &userdata->renderer.uniform);
|
sg_apply_uniforms(UB_fs_uniform, &userdata->renderer.uniform);
|
||||||
|
|
||||||
|
|
@ -88,6 +88,7 @@ static void init(void* _userdata)
|
||||||
// Initialize Sokol GFX.
|
// Initialize Sokol GFX.
|
||||||
sg_desc sgdesc = {
|
sg_desc sgdesc = {
|
||||||
.environment = sglue_environment(),
|
.environment = sglue_environment(),
|
||||||
|
.logger.func = slog_func,
|
||||||
};
|
};
|
||||||
sg_setup(&sgdesc);
|
sg_setup(&sgdesc);
|
||||||
if (!sg_isvalid()) {
|
if (!sg_isvalid()) {
|
||||||
|
|
@ -112,9 +113,13 @@ static void init(void* _userdata)
|
||||||
void* tmp_buffer = malloc(sizeof(position_t) * SAMPLE_COUNT);
|
void* tmp_buffer = malloc(sizeof(position_t) * SAMPLE_COUNT);
|
||||||
|
|
||||||
userdata->renderer = (renderer_t) {
|
userdata->renderer = (renderer_t) {
|
||||||
|
.pass = (sg_pass_action) {
|
||||||
|
.colors[0] = { .clear_value = { 0.0f, 0.0f, 0.0f, 1.0f }, .load_action = SG_LOADACTION_CLEAR }
|
||||||
|
},
|
||||||
.pipeline = sg_make_pipeline(&(sg_pipeline_desc) {
|
.pipeline = sg_make_pipeline(&(sg_pipeline_desc) {
|
||||||
.shader = sg_make_shader(base_shader_desc(sg_query_backend())),
|
.shader = sg_make_shader(base_shader_desc(sg_query_backend())),
|
||||||
.depth.write_enabled = true,
|
.depth.write_enabled = true,
|
||||||
|
.index_type = SG_INDEXTYPE_UINT16,
|
||||||
.layout.attrs = {
|
.layout.attrs = {
|
||||||
[ATTR_base_in_quad].format = SG_VERTEXFORMAT_FLOAT2,
|
[ATTR_base_in_quad].format = SG_VERTEXFORMAT_FLOAT2,
|
||||||
},
|
},
|
||||||
|
|
@ -123,9 +128,9 @@ static void init(void* _userdata)
|
||||||
.compute = true,
|
.compute = true,
|
||||||
.shader = sg_make_shader(compute_shader_desc(sg_query_backend())),
|
.shader = sg_make_shader(compute_shader_desc(sg_query_backend())),
|
||||||
}),*/
|
}),*/
|
||||||
.binding = &(sg_bindings) {
|
.binding = (sg_bindings) {
|
||||||
.vertex_buffers = {
|
.vertex_buffers = {
|
||||||
[0] = sg_make_buffer(&(sg_buffer_desc) {
|
[ATTR_base_in_quad] = sg_make_buffer(&(sg_buffer_desc) {
|
||||||
.type = SG_BUFFERTYPE_VERTEXBUFFER,
|
.type = SG_BUFFERTYPE_VERTEXBUFFER,
|
||||||
.data = SG_RANGE(quad),
|
.data = SG_RANGE(quad),
|
||||||
}),
|
}),
|
||||||
|
|
@ -144,7 +149,7 @@ static void init(void* _userdata)
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
.uniform = &SG_RANGE(uniform),
|
.uniform = SG_RANGE(uniform),
|
||||||
};
|
};
|
||||||
|
|
||||||
userdata->pan = (position_t) { .x = 0, .y = 0 };
|
userdata->pan = (position_t) { .x = 0, .y = 0 };
|
||||||
|
|
@ -213,6 +218,7 @@ sapp_desc sokol_main(int argc, char* argv[])
|
||||||
.cleanup_userdata_cb = cleanup,
|
.cleanup_userdata_cb = cleanup,
|
||||||
.event_userdata_cb = event,
|
.event_userdata_cb = event,
|
||||||
.window_title = "Sokol",
|
.window_title = "Sokol",
|
||||||
|
.logger.func = slog_func,
|
||||||
.allocator = {
|
.allocator = {
|
||||||
.alloc_fn = smemtrack_alloc,
|
.alloc_fn = smemtrack_alloc,
|
||||||
.free_fn = smemtrack_free,
|
.free_fn = smemtrack_free,
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,10 @@ layout(binding = 1) uniform fs_uniform {
|
||||||
float radius;
|
float radius;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
layout(location = 0) out vec4 frag_color;
|
||||||
layout(location = 1) in vec2 _quad;
|
layout(location = 1) in vec2 _quad;
|
||||||
layout(location = 2) in vec2 _centroid;
|
layout(location = 2) in vec2 _centroid;
|
||||||
layout(location = 3) flat in vec3 _color;
|
layout(location = 3) flat in vec3 _color;
|
||||||
layout(location = 4) out vec4 frag_color;
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue