This is a little slower, but means indirect draws can use Transform and Color.
There are other solutions for this. For example LÖVR could reserve
BaseInstance and use a compute shader to rewrite indirect buffers.
For now we choose to be correct and a little slower.
- Undeprecate ShaderType (it's good actually, kinda like a pipeline bind
point and more specific than having lovr trying to make sense of a
random set of stages).
- Use a default uniform block instead of push constants. The Constants
macro now maps to a uniform block declaration.
- It is no longer possible to create a shader by giving a single
DefaultShader string (you can still give a per-stage DefaultShader
though).
- lovr.graphics.compileShader now takes all stages instead of a single
stage. In general we need all stages when compiling GLSL because
default uniforms require linking across stages.
This shaves 20 bytes off of each model vertex, or around 40% savings.
The vertex size is also a power of two which results in extreme amounts
of style points.
+Z is the front face in a cubemap, not -Z. Currently cubemap faces are
flipped in both the X and Z directions.
Some kind of flip is required because cubemaps use a left-handed
coordinate space instead of lovr's/vulkan's right-handed coordinate
space.
Equirect does not need any changes.
- Cubemaps can have any layer count that is a multiple of 6.
- A cubemap with more than 6 layers will be a cubemap array image view.
- This isn't perfect because it conflates regular cubemaps with
6-layer cubemap arrays.
- Enable the vk feature, handle the spv feature, add getPixel helper.
- Add newSurface, which returns a "blank" surface, allowing you to set
your own properties.
- Add finalizeSurface, which sets computed surface properties and clamps
values to prepare for lighting.
- Add applyMaterial, which takes all of the properties in the material
and applies them to a surface
- Add helper functions for getting properties from the Material, which
combine scalar factors and texture samples while respecting shader
flags:
- getMaterialBaseColor
- getMaterialEmissive
- getMaterialMetalness
- getMaterialRoughness
- getMaterialOcclusion
- getMaterialClearcoat
- getMaterialClearcoatRoughness
- Add getDefaultSurface, which returns what initSurface would result in
today, deprecating initSurface.
- Last row of transform matrix is unused, make it 4x3
- Requires funny row-major packing due to vec3 std140 padding.
- Teach spirv parser to tolerate non-square matrix types, though
they aren't supported anywhere else yet.
- Compute cofactor in shader for normal matrix, ALU is free,
optimize out many terms, rm maf_cofactor.
- Take out complex UBO alignment logic since stuff is PO2 these days.
This was a common bottleneck for some workloads, so there are measurable
performance gains (up to 2x faster pass submission on CPU). GPU time is
identical, at least on desktop.
Pass stores draw commands rather than sending them to Vulkan
immediately.
The main motivation is to allow more flexibility in the Lua API. Passes
are now regular objects, aren't invalidated whenever submit is called,
and can cache their draws across multiple frames. Draws can also be
internally culled, sorted, and batched.
Some API methods (tallies) are missing, and there are still some bugs to
fix, notably with background color.
- Add Buffer:newReadback
- Add Buffer:getData
- Buffer:getPointer works with permanent buffers
- Buffer:setData works with permanent buffers
- Buffer:clear works with permanent buffers
- Add Texture:newReadback
- Add Texture:getPixels
- Add Texture:setPixels
- Add Texture:clear
- Add Texture:generateMipmaps
- Buffer readbacks can now return tables in addition to Blobs using Readback:getData
Tally is coming back soon with an improved API, it's temporarily removed
since it made the transfer rework a bit easier.
Note that synchronous readbacks (Buffer:getData, Texture:getPixels)
internally call lovr.graphics.submit, so they invalidate existing Pass
objects. This will be improved soon.
It doesn't work as intended (due to glslang issues?). The current way
to write a shader that uses multiple attachments is to declare multiple
output variables, which is a little better because you can name them
however you want and customize the type.
It would be nice to be able to support a "void" entrypoint for multiple
attachments so you don't need to awkwardly return the first target's
color, but I can't find a way around this right now.
It would be nice to do this in the importer, but it was 50+ lines and
was really tricky to write without reading from uncached GPU-mapped
memory. Instead, it's 1 line here.
I hope zero-weight vertices aren't a thing?
Now you can write var(0) instead of layout(set = 2, binding = 0).
The advantage is less typing and resilience in the event that the
default set changes.
The disadvantage is that now you can't use var.
- glowTexture is on by default, but still requires the glow flag.
- occlusionTexture is named ambientOcclusion, and is on by default,
but is still not used by any builtin shaders/helpers.
Sigh, back to getPass. I don't even know at this point. Basically now
that we came up with a half-solution for temp buffers, it makes sense to
apply this to passes as well, since we aren't going with the workstream
idea and temp passes are more convenient than retained passes.