Skip to content

Commit

Permalink
update sokol-zig dep and fixes for sokol-gfx bindings cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Nov 8, 2024
1 parent 29967db commit 41c56e5
Show file tree
Hide file tree
Showing 4 changed files with 351 additions and 338 deletions.
4 changes: 2 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
.dependencies = .{
// sokol only needed for the actual emulators
.sokol = .{
.url = "git+https://github.com/floooh/sokol-zig.git#fe47d2055d7b86bdcbaf02610109b1f1aa5dfdc1",
.hash = "12201b62a6fd9e15e0b78a4fbcda3ac907a423446c68c6b8614c9b3b21d24a955639",
.url = "git+https://github.com/floooh/sokol-zig.git#6ac38c06751b320fdf67ba81e86e03aebaf1a0d4",
.hash = "1220f0dab58f9fa0d140f8087405d1bcad99b7a913a9d78abf9c4d74a266992ab898",
},
},
.paths = .{
Expand Down
12 changes: 6 additions & 6 deletions emus/host/gfx.zig
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ pub fn draw(opts: DrawOptions) void {
sg.applyBindings(init: {
var bind: sg.Bindings = .{};
bind.vertex_buffers[0] = state.offscreen.vbuf;
bind.fs.images[shaders.SLOT_fb_tex] = state.fb.img;
bind.fs.images[shaders.SLOT_pal_tex] = state.fb.pal_img;
bind.fs.samplers[shaders.SLOT_smp] = state.fb.smp;
bind.images[shaders.IMG_fb_tex] = state.fb.img;
bind.images[shaders.IMG_pal_tex] = state.fb.pal_img;
bind.samplers[shaders.SMP_smp] = state.fb.smp;
break :init bind;
});
const vs_params = shaders.OffscreenVsParams{ .uv_offset = .{
Expand All @@ -287,7 +287,7 @@ pub fn draw(opts: DrawOptions) void {
asF32(state.offscreen.view.width) / asF32(state.fb.dim.width),
asF32(state.offscreen.view.height) / asF32(state.fb.dim.height),
} };
sg.applyUniforms(.VS, shaders.SLOT_offscreen_vs_params, sg.asRange(&vs_params));
sg.applyUniforms(shaders.UB_offscreen_vs_params, sg.asRange(&vs_params));
sg.draw(0, 4, 1);
sg.endPass();

Expand All @@ -304,8 +304,8 @@ pub fn draw(opts: DrawOptions) void {
sg.applyBindings(init: {
var bind = sg.Bindings{};
bind.vertex_buffers[0] = state.display.vbuf;
bind.fs.images[shaders.SLOT_tex] = state.offscreen.img;
bind.fs.samplers[shaders.SLOT_smp] = state.offscreen.smp;
bind.images[shaders.IMG_tex] = state.offscreen.img;
bind.samplers[shaders.SMP_smp] = state.offscreen.smp;
break :init bind;
});
sg.draw(0, 4, 1);
Expand Down
16 changes: 8 additions & 8 deletions emus/host/shaders.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout(location=0) in vec2 in_pos;
layout(location=1) in vec2 in_uv;

uniform offscreen_vs_params {
layout(binding=0) uniform offscreen_vs_params {
vec2 uv_offset;
vec2 uv_scale;
};
Expand All @@ -15,8 +15,8 @@ void main() {
@end

@fs offscreen_fs
uniform texture2D fb_tex;
uniform sampler smp;
layout(binding=0) uniform texture2D fb_tex;
layout(binding=0) uniform sampler smp;
in vec2 uv;
out vec4 frag_color;
void main() {
Expand All @@ -26,9 +26,9 @@ void main() {

// offscreen shader with color palette decoding
@fs offscreen_pal_fs
uniform texture2D fb_tex;
uniform texture2D pal_tex;
uniform sampler smp;
layout(binding=0) uniform texture2D fb_tex;
layout(binding=1) uniform texture2D pal_tex;
layout(binding=0) uniform sampler smp;
in vec2 uv;
out vec4 frag_color;
void main() {
Expand All @@ -48,8 +48,8 @@ void main() {
@end

@fs display_fs
uniform texture2D tex;
uniform sampler smp;
layout(binding=0) uniform texture2D tex;
layout(binding=0) uniform sampler smp;
in vec2 uv;
out vec4 frag_color;

Expand Down
Loading

0 comments on commit 41c56e5

Please sign in to comment.