Shader upade works on windows

This commit is contained in:
John Alanbrook 2024-05-15 16:34:03 -05:00
parent cadf10b3a9
commit f4ee9d8228
6 changed files with 26 additions and 5 deletions

View file

@ -129,7 +129,7 @@ qq = 'ms';
profile.report = function(start, msg = "[undefined report]") profile.report = function(start, msg = "[undefined report]")
{ {
console.info(`${msg} in ${profile.best_t(profile.now()-start)}`); say(`${msg} in ${profile.best_t(profile.now()-start)}`);
} }
profile.addreport = function(cache, line, start) profile.addreport = function(cache, line, start)

View file

@ -152,6 +152,8 @@ var shaderlang = {
ios: "metal_ios", ios: "metal_ios",
} }
say(`shaderlang is ${shaderlang[os.sys()]}`);
var attr_map = { var attr_map = {
a_pos: 0, a_pos: 0,
a_uv: 1, a_uv: 1,
@ -296,7 +298,7 @@ render.make_shader = function(shader)
io.slurpwrite(out, shader); io.slurpwrite(out, shader);
var backend = shaderlang[os.sys()]; var backend = shaderlang[os.sys()];
var ret = os.system(`sokol-shdc -b -f bare_yaml --slang=${backend} -i ${out} -o ${out}`); var ret = os.system(`sokol-shdc -f bare_yaml --slang=${backend} -i ${out} -o ${out}`);
if (ret) { if (ret) {
console.info(`error compiling shader`); console.info(`error compiling shader`);
return; return;

View file

@ -455,8 +455,8 @@ function cmd_args(cmdargs)
if (cmds.length === 0) if (cmds.length === 0)
cmds[0] = "play"; cmds[0] = "play";
else if (!Cmdline.orders[cmds[0]]) { else if (!Cmdline.orders[cmds[0]]) {
console.warn(`Command ${cmds[0]} not found.`); console.warn(`Command ${cmds[0]} not found. Playing instead.`);
return; cmds[0] = "play";
} }
Cmdline.orders[cmds[0]](cmds.slice(1)); Cmdline.orders[cmds[0]](cmds.slice(1));

View file

@ -1,4 +1,3 @@
var inputpanel = { var inputpanel = {
title: "untitled", title: "untitled",
toString() { return this.title; }, toString() { return this.title; },

View file

@ -64,6 +64,13 @@ const char *js2str(JSValue v) {
return JS_ToCString(js, v); return JS_ToCString(js, v);
} }
char *js2strdup(JSValue v) {
char *str = JS_ToCString(js, v);
char *ret = strdup(str);
JS_FreeCString(js, str);
return ret;
}
void sg_buffer_free(sg_buffer *b) void sg_buffer_free(sg_buffer *b)
{ {
sg_destroy_buffer(*b); sg_destroy_buffer(*b);
@ -747,6 +754,15 @@ sg_shader js2shader(JSValue v)
char *fsmain = js2str(js_getpropstr(fs, "entry_point")); char *fsmain = js2str(js_getpropstr(fs, "entry_point"));
desc.vs.entry = vsmain; desc.vs.entry = vsmain;
desc.fs.entry = fsmain; desc.fs.entry = fsmain;
desc.vs.d3d11_target = "vs_4_0";
desc.fs.d3d11_target = "ps_4_0";
JSValue attrs = js_getpropstr(vs, "inputs");
int atin = js_arrlen(attrs);
for (int i = 0; i < atin; i++) {
JSValue u = js_getpropidx(attrs, i);
desc.attrs[i].sem_name = js2strdup(js_getpropstr(u,"sem_name"));
desc.attrs[i].sem_index = js2number(js_getpropstr(u, "sem_index"));
}
JSValue vsu = js_getpropstr(vs, "uniform_blocks"); JSValue vsu = js_getpropstr(vs, "uniform_blocks");
int unin = js_arrlen(vsu); int unin = js_arrlen(vsu);
for (int i = 0; i < unin; i++) { for (int i = 0; i < unin; i++) {

View file

@ -15,6 +15,10 @@
#include "script.h" #include "script.h"
#ifdef __WIN32
#include "debugapi.h"
#endif
#define ESC "\033[" #define ESC "\033["
#define BLACK 30 #define BLACK 30
#define RED 31 #define RED 31