-
-
Notifications
You must be signed in to change notification settings - Fork 239
Vulkan text support #3582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Wunka
wants to merge
24
commits into
PixelGuys:master
Choose a base branch
from
Wunka:vulkanText
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Vulkan text support #3582
Changes from 18 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
ca2724d
Change format from SRGB to UNORM
IntegratedQuantum 673c868
Assert that push constants use extern structs, nothing else makes sen…
IntegratedQuantum a379684
Create image view and sampler
IntegratedQuantum f6502ae
Bind the image to the CommandBuffer
IntegratedQuantum 00f760b
Use vulkan for image drawing and change the interface accordingly
IntegratedQuantum e93e9b9
Do the OpenGL image and pipeline binding in the OpenGL branch
IntegratedQuantum 6f5e8a6
nine-slice rendering
IntegratedQuantum 81e6f68
custom shaded image
IntegratedQuantum 01dc7a9
Simplify again
IntegratedQuantum 4945aee
Custom shaded rect in vulkan
IntegratedQuantum 5a1112a
Less verbose image binding for CommandBuffer
IntegratedQuantum 8f0cfff
first whatever
Wunka 8479ef4
Merge remote-tracking branch 'Quantum/vulkan_more_images' into vulkan…
Wunka 4fa1c61
nice!
Wunka cd6edb0
Merge remote-tracking branch 'upstream/master' into vulkanText
Wunka e39d9e1
wow....
Wunka 1e4514a
remove bufferOffset
Wunka b6de05d
almost done
Wunka 4bfb401
finally working!
Wunka 382f69f
remove debug print
Wunka 1c887d6
make drawGlyph look better
Wunka e8078c5
do a few things
Wunka 905daee
do barriers
Wunka 283e360
do commands in one and do less conversion
Wunka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1083,15 +1083,34 @@ pub const TextBuffer = struct { // MARK: TextBuffer | |
| defer draw.restoreScale(oldScale); | ||
| var x: f32 = 0; | ||
| var y: f32 = 0; | ||
| TextRendering.pipeline.bind(draw.getScissor()); | ||
| var viewport: [4]c_int = undefined; | ||
| c.glGetIntegerv(c.GL_VIEWPORT, &viewport); | ||
| c.glUniform2f(TextRendering.uniforms.scene, @floatFromInt(viewport[2]), @floatFromInt(viewport[3])); | ||
| c.glUniform1f(TextRendering.uniforms.ratio, draw.scale); | ||
| c.glUniform1ui(TextRendering.uniforms.inColor, @bitCast(draw.getColor())); | ||
| c.glActiveTexture(c.GL_TEXTURE0); | ||
| c.glBindTexture(c.GL_TEXTURE_2D, TextRendering.glyphTexture[0]); | ||
| draw.rectVao.bind(); | ||
|
|
||
| if (main.settings.launchConfig.vulkanTestingMode) { | ||
| vulkan.currentFrame.guiCommands.bindPipeline(TextRendering.pipeline, draw.getScissor()); | ||
| vulkan.currentFrame.guiCommands.pushConstants(TextRendering.pipeline, &TextRendering.CompleteUniforms{ | ||
| .glyphData = undefined, | ||
| .scene = .{@floatFromInt(viewport[2]), @floatFromInt(viewport[3])}, | ||
| .ratio = draw.scale, | ||
| .inColor = @bitCast(draw.getColor()), | ||
| .fontSize = .{@floatFromInt(TextRendering.textureWidth), @floatFromInt(TextRendering.textureHeight)}, | ||
| }); | ||
| vulkan.currentFrame.guiCommands.bindDescriptors(TextRendering.pipeline, .graphics, 0, &.{ | ||
| .{.image = .{.binding = 0, .image = TextRendering.glyphTexture[0].vulkanImage.?}}, | ||
| }); | ||
|
|
||
| vulkan.currentFrame.guiCommands.bindVertexArray(draw.rectVao); | ||
| } else { | ||
| TextRendering.pipeline.bind(draw.getScissor()); | ||
|
|
||
| c.glUniform2f(TextRendering.uniforms.scene, @floatFromInt(viewport[2]), @floatFromInt(viewport[3])); | ||
| c.glUniform1f(TextRendering.uniforms.ratio, draw.scale); | ||
| c.glUniform1ui(TextRendering.uniforms.inColor, @bitCast(draw.getColor())); | ||
| c.glActiveTexture(c.GL_TEXTURE0); | ||
| c.glBindTexture(c.GL_TEXTURE_2D, TextRendering.glyphTexture[0].textureID); | ||
|
|
||
| draw.rectVao.bind(); | ||
| } | ||
| const lineWraps: []f32 = main.stackAllocator.alloc(f32, self.lineBreaks.items.len - 1); | ||
| defer main.stackAllocator.free(lineWraps); | ||
| var i: usize = 0; | ||
|
|
@@ -1150,15 +1169,33 @@ pub const TextBuffer = struct { // MARK: TextBuffer | |
| defer draw.restoreScale(oldScale); | ||
| var x: f32 = 0; | ||
| var y: f32 = 0; | ||
| TextRendering.pipeline.bind(draw.getScissor()); | ||
| var viewport: [4]c_int = undefined; | ||
| c.glGetIntegerv(c.GL_VIEWPORT, &viewport); | ||
| c.glUniform2f(TextRendering.uniforms.scene, @floatFromInt(viewport[2]), @floatFromInt(viewport[3])); | ||
| c.glUniform1f(TextRendering.uniforms.ratio, draw.scale); | ||
| c.glUniform1ui(TextRendering.uniforms.inColor, @bitCast(draw.getColor())); | ||
| c.glActiveTexture(c.GL_TEXTURE0); | ||
| c.glBindTexture(c.GL_TEXTURE_2D, TextRendering.glyphTexture[0]); | ||
| draw.rectVao.bind(); | ||
|
|
||
| if (main.settings.launchConfig.vulkanTestingMode) { | ||
| vulkan.currentFrame.guiCommands.bindPipeline(TextRendering.pipeline, draw.getScissor()); | ||
| vulkan.currentFrame.guiCommands.pushConstants(TextRendering.pipeline, &TextRendering.CompleteUniforms{ | ||
| .glyphData = undefined, | ||
| .scene = .{@floatFromInt(viewport[2]), @floatFromInt(viewport[3])}, | ||
| .ratio = draw.scale, | ||
| .inColor = @bitCast(draw.getColor()), | ||
| .fontSize = .{@floatFromInt(TextRendering.textureWidth), @floatFromInt(TextRendering.textureHeight)}, | ||
| }); | ||
| vulkan.currentFrame.guiCommands.bindDescriptors(TextRendering.pipeline, .graphics, 0, &.{ | ||
| .{.image = .{.binding = 0, .image = TextRendering.glyphTexture[0].vulkanImage.?}}, | ||
| }); | ||
|
|
||
| vulkan.currentFrame.guiCommands.bindVertexArray(draw.rectVao); | ||
| } else { | ||
| TextRendering.pipeline.bind(draw.getScissor()); | ||
|
|
||
| c.glUniform2f(TextRendering.uniforms.scene, @floatFromInt(viewport[2]), @floatFromInt(viewport[3])); | ||
| c.glUniform1f(TextRendering.uniforms.ratio, draw.scale); | ||
| c.glUniform1ui(TextRendering.uniforms.inColor, @bitCast(draw.getColor())); | ||
| c.glActiveTexture(c.GL_TEXTURE0); | ||
| c.glBindTexture(c.GL_TEXTURE_2D, TextRendering.glyphTexture[0].textureID); | ||
| draw.rectVao.bind(); | ||
| } | ||
| const lineWraps: []f32 = main.stackAllocator.alloc(f32, self.lineBreaks.items.len - 1); | ||
| defer main.stackAllocator.free(lineWraps); | ||
| var i: usize = 0; | ||
|
|
@@ -1220,13 +1257,28 @@ const TextRendering = struct { // MARK: TextRendering | |
| fontSize: c_int, | ||
| } = undefined; | ||
|
|
||
| const CompleteUniforms = extern struct { | ||
| glyphData: GlypUniforms, | ||
| scene: [2]f32 align(8), | ||
| ratio: f32, | ||
| inColor: c_uint, | ||
| fontSize: [2]f32 align(8), | ||
| }; | ||
|
|
||
| const GlypUniforms = extern struct { | ||
| textureRect: [4]f32 align(16), | ||
| offset: [2]f32 align(8), | ||
| fontEffects: c_int, | ||
| textureBounds: [4]f32 align(16), | ||
| }; | ||
|
|
||
| var freetypeLib: c.FT_Library = undefined; | ||
| var freetypeFace: c.FT_Face = undefined; | ||
| var harfbuzzFace: ?*c.hb_face_t = undefined; | ||
| var harfbuzzFont: ?*c.hb_font_t = undefined; | ||
| var glyphMapping: main.ListManaged(u31) = undefined; | ||
| var glyphData: main.ListManaged(Glyph) = undefined; | ||
| var glyphTexture: [2]c_uint = undefined; | ||
| var glyphTexture: [2]Texture = undefined; | ||
| var textureWidth: i32 = 1024; | ||
| const textureHeight: i32 = 16; | ||
| var textureOffset: i32 = 0; | ||
|
|
@@ -1247,14 +1299,14 @@ const TextRendering = struct { // MARK: TextRendering | |
| &uniforms, | ||
| draw.SimpleVertex2D, | ||
| .{ | ||
| .bindings = &.{.sampler(0, .{.fragment = true})}, | ||
| .rasterState = .{.cullMode = .none}, | ||
| .depthStencilState = .{.depthTest = false, .depthWrite = false}, | ||
| .blendState = .{.attachments = &.{.alphaBlending}, .formats = &.{.{.custom = c.VK_FORMAT_R8_UNORM}}}, | ||
| .blendState = .{.attachments = &.{.alphaBlending}, .formats = &.{.swapChain}}, | ||
| .inputAssemblyState = .{.topology = .triangleStrip}, | ||
| .pushConstantSize = @sizeOf(CompleteUniforms), | ||
| }, | ||
| ); | ||
| pipeline.bind(null); | ||
| errdefer pipeline.deinit(); | ||
| c.glUniform2f(uniforms.fontSize, @floatFromInt(textureWidth), @floatFromInt(textureHeight)); | ||
| try ftError(c.FT_Init_FreeType(&freetypeLib)); | ||
| try ftError(c.FT_New_Face(freetypeLib, "assets/cubyz/fonts/unscii-16-full.ttf", 0, &freetypeFace)); | ||
| try ftError(c.FT_Set_Pixel_Sizes(freetypeFace, 0, textureHeight)); | ||
|
|
@@ -1265,26 +1317,46 @@ const TextRendering = struct { // MARK: TextRendering | |
| glyphMapping = .init(main.globalAllocator); | ||
| glyphData = .init(main.globalAllocator); | ||
| glyphData.append(undefined); // 0 is a reserved value. | ||
| c.glGenTextures(2, &glyphTexture); | ||
| c.glBindTexture(c.GL_TEXTURE_2D, glyphTexture[0]); | ||
| c.glTexImage2D(c.GL_TEXTURE_2D, 0, c.GL_R8, textureWidth, textureHeight, 0, c.GL_RED, c.GL_UNSIGNED_BYTE, null); | ||
| c.glTexParameteri(c.GL_TEXTURE_2D, c.GL_TEXTURE_MIN_FILTER, c.GL_NEAREST); | ||
| c.glTexParameteri(c.GL_TEXTURE_2D, c.GL_TEXTURE_MAG_FILTER, c.GL_NEAREST); | ||
| c.glTexParameteri(c.GL_TEXTURE_2D, c.GL_TEXTURE_WRAP_S, c.GL_REPEAT); | ||
| c.glTexParameteri(c.GL_TEXTURE_2D, c.GL_TEXTURE_WRAP_T, c.GL_REPEAT); | ||
| c.glBindTexture(c.GL_TEXTURE_2D, glyphTexture[1]); | ||
| c.glTexParameteri(c.GL_TEXTURE_2D, c.GL_TEXTURE_MIN_FILTER, c.GL_NEAREST); | ||
| c.glTexParameteri(c.GL_TEXTURE_2D, c.GL_TEXTURE_MAG_FILTER, c.GL_NEAREST); | ||
| c.glTexParameteri(c.GL_TEXTURE_2D, c.GL_TEXTURE_WRAP_S, c.GL_REPEAT); | ||
| c.glTexParameteri(c.GL_TEXTURE_2D, c.GL_TEXTURE_WRAP_T, c.GL_REPEAT); | ||
| glyphTexture = .{ | ||
| .init(), | ||
| .init(), | ||
| }; | ||
|
|
||
| if (main.settings.launchConfig.vulkanTestingMode) { | ||
| vulkan.currentFrame.guiCommands.bindPipeline(TextRendering.pipeline, null); | ||
| errdefer pipeline.deinit(); | ||
|
|
||
| glyphTexture[0].vulkanImage = vulkan.Image.init(.{textureWidth, textureHeight, 1}, .{ | ||
| .format = c.VK_FORMAT_R8_UNORM, | ||
| .usage = c.VK_IMAGE_USAGE_TRANSFER_DST_BIT | c.VK_IMAGE_USAGE_SAMPLED_BIT | c.VK_IMAGE_USAGE_TRANSFER_SRC_BIT, | ||
| }); | ||
| } else { | ||
| pipeline.bind(null); | ||
| errdefer pipeline.deinit(); | ||
| c.glUniform2f(uniforms.fontSize, @floatFromInt(textureWidth), @floatFromInt(textureHeight)); | ||
| glyphTexture[0].bind(); | ||
|
|
||
| c.glTexImage2D(c.GL_TEXTURE_2D, 0, c.GL_R8, textureWidth, textureHeight, 0, c.GL_RED, c.GL_UNSIGNED_BYTE, null); | ||
| c.glTexParameteri(c.GL_TEXTURE_2D, c.GL_TEXTURE_MIN_FILTER, c.GL_NEAREST); | ||
| c.glTexParameteri(c.GL_TEXTURE_2D, c.GL_TEXTURE_MAG_FILTER, c.GL_NEAREST); | ||
| c.glTexParameteri(c.GL_TEXTURE_2D, c.GL_TEXTURE_WRAP_S, c.GL_REPEAT); | ||
| c.glTexParameteri(c.GL_TEXTURE_2D, c.GL_TEXTURE_WRAP_T, c.GL_REPEAT); | ||
| glyphTexture[1].bind(); | ||
|
|
||
| c.glTexParameteri(c.GL_TEXTURE_2D, c.GL_TEXTURE_MIN_FILTER, c.GL_NEAREST); | ||
| c.glTexParameteri(c.GL_TEXTURE_2D, c.GL_TEXTURE_MAG_FILTER, c.GL_NEAREST); | ||
| c.glTexParameteri(c.GL_TEXTURE_2D, c.GL_TEXTURE_WRAP_S, c.GL_REPEAT); | ||
| c.glTexParameteri(c.GL_TEXTURE_2D, c.GL_TEXTURE_WRAP_T, c.GL_REPEAT); | ||
| } | ||
| } | ||
|
|
||
| fn deinit() void { | ||
| pipeline.deinit(); | ||
| ftError(c.FT_Done_FreeType(freetypeLib)) catch {}; | ||
| glyphMapping.deinit(); | ||
| glyphData.deinit(); | ||
| c.glDeleteTextures(2, &glyphTexture); | ||
| glyphTexture[0].deinit(); | ||
| glyphTexture[1].deinit(); | ||
| c.hb_font_destroy(harfbuzzFont); | ||
| } | ||
|
|
||
|
|
@@ -1293,23 +1365,41 @@ const TextRendering = struct { // MARK: TextRendering | |
| const swap = glyphTexture[1]; | ||
| glyphTexture[1] = glyphTexture[0]; | ||
| glyphTexture[0] = swap; | ||
| c.glActiveTexture(c.GL_TEXTURE0); | ||
| c.glBindTexture(c.GL_TEXTURE_2D, glyphTexture[0]); | ||
| c.glTexImage2D(c.GL_TEXTURE_2D, 0, c.GL_R8, newWidth, textureHeight, 0, c.GL_RED, c.GL_UNSIGNED_BYTE, null); | ||
| c.glCopyImageSubData(glyphTexture[1], c.GL_TEXTURE_2D, 0, 0, 0, 0, glyphTexture[0], c.GL_TEXTURE_2D, 0, 0, 0, 0, textureOffset, textureHeight, 1); | ||
| pipeline.bind(draw.getScissor()); | ||
| c.glUniform2f(uniforms.fontSize, @floatFromInt(textureWidth), @floatFromInt(textureHeight)); | ||
| if (main.settings.launchConfig.vulkanTestingMode) { | ||
| glyphTexture[0].vulkanImage = vulkan.Image.init(.{textureWidth, textureHeight, 1}, .{ | ||
| .format = c.VK_FORMAT_R8_UNORM, | ||
| .usage = c.VK_IMAGE_USAGE_TRANSFER_DST_BIT | c.VK_IMAGE_USAGE_SAMPLED_BIT | c.VK_IMAGE_USAGE_TRANSFER_SRC_BIT, | ||
| }); | ||
| glyphTexture[0].vulkanImage.?.uploadImage(glyphTexture[1].vulkanImage.?); | ||
| glyphTexture[1].vulkanImage.?.deferredDeinit(); | ||
|
IntegratedQuantum marked this conversation as resolved.
Outdated
|
||
| } else { | ||
| c.glActiveTexture(c.GL_TEXTURE0); | ||
| c.glBindTexture(c.GL_TEXTURE_2D, glyphTexture[0].textureID); | ||
| c.glTexImage2D(c.GL_TEXTURE_2D, 0, c.GL_R8, newWidth, textureHeight, 0, c.GL_RED, c.GL_UNSIGNED_BYTE, null); | ||
| c.glCopyImageSubData(glyphTexture[1].textureID, c.GL_TEXTURE_2D, 0, 0, 0, 0, glyphTexture[0].textureID, c.GL_TEXTURE_2D, 0, 0, 0, 0, textureOffset, textureHeight, 1); | ||
|
|
||
| pipeline.bind(draw.getScissor()); | ||
| c.glUniform2f(uniforms.fontSize, @floatFromInt(textureWidth), @floatFromInt(textureHeight)); | ||
| } | ||
| } | ||
|
|
||
| fn uploadData(bitmap: c.FT_Bitmap) void { | ||
| const width: i32 = @bitCast(bitmap.width); | ||
| const height: i32 = @bitCast(bitmap.rows); | ||
| const pitch: i32 = @bitCast(bitmap.pitch); | ||
| const buffer = bitmap.buffer orelse return; | ||
| if (textureOffset + width > textureWidth) { | ||
| resizeTexture(textureWidth*2); | ||
| } | ||
| c.glPixelStorei(c.GL_UNPACK_ALIGNMENT, 1); | ||
| c.glTexSubImage2D(c.GL_TEXTURE_2D, 0, textureOffset, 0, width, height, c.GL_RED, c.GL_UNSIGNED_BYTE, buffer); | ||
| if (main.settings.launchConfig.vulkanTestingMode) { | ||
| glyphTexture[0].vulkanImage.?.size = .{width, height, 1}; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is still wrong (see other comment) |
||
| glyphTexture[0].vulkanImage.?.uploadData(buffer[0..@intCast(pitch*height)], .{ | ||
| .imageOffset = .{.x = textureOffset}, | ||
| }); | ||
| } else { | ||
| c.glPixelStorei(c.GL_UNPACK_ALIGNMENT, 1); | ||
| c.glTexSubImage2D(c.GL_TEXTURE_2D, 0, textureOffset, 0, width, height, c.GL_RED, c.GL_UNSIGNED_BYTE, buffer); | ||
| } | ||
| textureOffset += width; | ||
| } | ||
|
|
||
|
|
@@ -1344,16 +1434,41 @@ const TextRendering = struct { // MARK: TextRendering | |
| y += draw.translation[1]; | ||
| x = @floor(x); | ||
| y = @ceil(y); | ||
| c.glUniform1i(uniforms.fontEffects, fontEffects); | ||
| c.glUniform4f(uniforms.textureBounds, @floatFromInt(glyph.textureX), 0, @floatFromInt(glyph.size[0]), @floatFromInt(glyph.size[1])); | ||
|
|
||
| if (fontEffects & 0x1000000 != 0) { // bold | ||
| c.glUniform2f(uniforms.offset, @as(f32, @floatFromInt(glyph.bearing[0]))*draw.scale + x - 1, @as(f32, @floatFromInt(glyph.bearing[1]))*draw.scale + y - 1); | ||
| c.glUniform4f(uniforms.textureRect, @floatFromInt(glyph.textureX - 1), -1, @floatFromInt(glyph.size[0] + 2), @floatFromInt(glyph.size[1] + 2)); | ||
| if (main.settings.launchConfig.vulkanTestingMode) { | ||
| vulkan.currentFrame.guiCommands.pushConstants(TextRendering.pipeline, &GlypUniforms{ | ||
| .textureRect = .{@floatFromInt(glyph.textureX - 1), -1, @floatFromInt(glyph.size[0] + 2), @floatFromInt(glyph.size[1] + 2)}, | ||
| .offset = .{@as(f32, @floatFromInt(glyph.bearing[0]))*draw.scale + x - 1, @as(f32, @floatFromInt(glyph.bearing[1]))*draw.scale + y - 1}, | ||
| .fontEffects = fontEffects, | ||
| .textureBounds = .{@floatFromInt(glyph.textureX), 0, @floatFromInt(glyph.size[0]), @floatFromInt(glyph.size[1])}, | ||
| }); | ||
| } else { | ||
| c.glUniform1i(uniforms.fontEffects, fontEffects); | ||
| c.glUniform4f(uniforms.textureBounds, @floatFromInt(glyph.textureX), 0, @floatFromInt(glyph.size[0]), @floatFromInt(glyph.size[1])); | ||
| c.glUniform2f(uniforms.offset, @as(f32, @floatFromInt(glyph.bearing[0]))*draw.scale + x - 1, @as(f32, @floatFromInt(glyph.bearing[1]))*draw.scale + y - 1); | ||
| c.glUniform4f(uniforms.textureRect, @floatFromInt(glyph.textureX - 1), -1, @floatFromInt(glyph.size[0] + 2), @floatFromInt(glyph.size[1] + 2)); | ||
| } | ||
| } else { | ||
| c.glUniform2f(uniforms.offset, @as(f32, @floatFromInt(glyph.bearing[0]))*draw.scale + x, @as(f32, @floatFromInt(glyph.bearing[1]))*draw.scale + y); | ||
| c.glUniform4f(uniforms.textureRect, @floatFromInt(glyph.textureX), 0, @floatFromInt(glyph.size[0]), @floatFromInt(glyph.size[1])); | ||
| if (main.settings.launchConfig.vulkanTestingMode) { | ||
| vulkan.currentFrame.guiCommands.pushConstants(TextRendering.pipeline, &GlypUniforms{ | ||
| .textureRect = .{@floatFromInt(glyph.textureX), 0, @floatFromInt(glyph.size[0]), @floatFromInt(glyph.size[1])}, | ||
| .offset = .{@as(f32, @floatFromInt(glyph.bearing[0]))*draw.scale + x, @as(f32, @floatFromInt(glyph.bearing[1]))*draw.scale + y}, | ||
| .fontEffects = fontEffects, | ||
| .textureBounds = .{@floatFromInt(glyph.textureX), 0, @floatFromInt(glyph.size[0]), @floatFromInt(glyph.size[1])}, | ||
| }); | ||
| } else { | ||
| c.glUniform1i(uniforms.fontEffects, fontEffects); | ||
| c.glUniform4f(uniforms.textureBounds, @floatFromInt(glyph.textureX), 0, @floatFromInt(glyph.size[0]), @floatFromInt(glyph.size[1])); | ||
| c.glUniform2f(uniforms.offset, @as(f32, @floatFromInt(glyph.bearing[0]))*draw.scale + x, @as(f32, @floatFromInt(glyph.bearing[1]))*draw.scale + y); | ||
| c.glUniform4f(uniforms.textureRect, @floatFromInt(glyph.textureX), 0, @floatFromInt(glyph.size[0]), @floatFromInt(glyph.size[1])); | ||
| } | ||
| } | ||
|
IntegratedQuantum marked this conversation as resolved.
|
||
| if (main.settings.launchConfig.vulkanTestingMode) { | ||
| vulkan.currentFrame.guiCommands.draw(4, 0); | ||
| } else { | ||
| c.glDrawArrays(c.GL_TRIANGLE_STRIP, 0, 4); | ||
| } | ||
| c.glDrawArrays(c.GL_TRIANGLE_STRIP, 0, 4); | ||
| } | ||
|
|
||
| fn renderText(text: []const u8, x: f32, y: f32, fontSize: f32, initialFontEffect: TextBuffer.FontEffect) void { | ||
|
|
@@ -2043,7 +2158,7 @@ pub const Texture = struct { // MARK: Texture | |
| self.vulkanImage = vulkan.Image.init(.{image.width, image.height, 1}, .{ | ||
| .usage = c.VK_IMAGE_USAGE_TRANSFER_DST_BIT | c.VK_IMAGE_USAGE_SAMPLED_BIT, | ||
| }); | ||
| self.vulkanImage.?.uploadData(0, std.mem.sliceAsBytes(image.imageData)); | ||
| self.vulkanImage.?.uploadData(std.mem.sliceAsBytes(image.imageData), .{}); | ||
| } | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.