Skip to content
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

Graphics improvements #565

Merged
merged 50 commits into from
Feb 22, 2023
Merged

Graphics improvements #565

merged 50 commits into from
Feb 22, 2023

Conversation

guusw
Copy link
Member

@guusw guusw commented Feb 13, 2023

Graphics improvements

PR contains several changes I made while working on a simple PBR demo, porting over the shaders from the bgfx days.

For now, the demo code can be found here: https://github.com/shards-lang/pbr-demo (run entry.edn)

Generators

Adds the concept of generators:

(GFX.Feature :ViewGenerators (->
  (GFX.Texture ...) >= .tex
  (GFX.RenderInto :Textures {:color .tex})
  {:myTexture .tex}))

Which when added, will run the generator for each unique View being rendered, and the resulting table will be injected as shader paramters.

To precompute once and reuse forever you can wrap your code inside (Setup) inside the generator

Note that this also replaces DrawData previously available on Feature, so something like the following can be used to replace the previous DrawData usages:

(GFX.Feature :ViewGenerators (->
   {:time 3.0 :baseColor (Float4 1.0)}))

If you need to pass data to the generator, channels should be used.

Render target creation

Renderable textures can now be created using the same Texture shard, but passing it a Format and Size.

(GFX.Texture :Format TextureFormat.RGBA8UnormSrgb :Resolution (Int2 1024) :Dimension TextureDimension.D2)
(GFX.Texture :Format TextureFormat.RGBA8UnormSrgb :Resolution .size :MipLevels .num-mips :Dimension TextureDimension.Cube)

In addition parameters are supported for most fields and Cubemap and mip levels were added.

RenderInto

A dedicated shard was added to push a collection of render attachments onto the view stack

(GFX.Texture) >= .cube-tex
(GFX.Texture) >= .velocity-tex
(GFX.RenderInto
  :Textures {
         :color {:Texture cube-tex :Face n :Mip mip-index}
         :velocity .velocity-tex }
  :Contents (-> (GFX.Render :Steps steps :View .view))))

Attachments can be a whole texture, a specific mip or cubemap (array) layer. The attachments will bind to the named outputs specified on any of the render steps.

This also replaces the previous UI rendering (GFX.Region) shards, now you'd use the RenderInto shard for this as well, but pass the :WindowRegion argument as well

@guusw guusw mentioned this pull request Feb 14, 2023
1 task
Base automatically changed from guus/fixes-1 to devel February 14, 2023 08:08
@guusw guusw force-pushed the guus/pbr branch 2 times, most recently from 8ce714b to 27ee0db Compare February 16, 2023 06:30
@codecov
Copy link

codecov bot commented Feb 16, 2023

Codecov Report

Merging #565 (280712f) into devel (112704e) will decrease coverage by 0.48%.
The diff coverage is 75.99%.

@@            Coverage Diff             @@
##            devel     #565      +/-   ##
==========================================
- Coverage   81.38%   80.90%   -0.48%     
==========================================
  Files         243      244       +1     
  Lines       30070    30731     +661     
==========================================
+ Hits        24472    24864     +392     
- Misses       5598     5867     +269     
Impacted Files Coverage Δ
include/shards.hpp 95.25% <ø> (+0.02%) ⬆️
src/extra/gfx.hpp 66.66% <ø> (ø)
src/extra/gfx/shader/translator.hpp 87.35% <ø> (ø)
src/extra/gfx/shards_types.hpp 100.00% <ø> (ø)
src/gfx/context.cpp 77.95% <ø> (-0.69%) ⬇️
src/gfx/drawable_processor.hpp 100.00% <ø> (ø)
src/gfx/gltf/gltf.cpp 82.38% <ø> (ø)
src/gfx/isb.hpp 100.00% <ø> (ø)
src/gfx/params.hpp 80.00% <ø> (-20.00%) ⬇️
src/gfx/pipeline_builder.hpp 75.00% <ø> (ø)
... and 98 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@guusw guusw requested review from Kryptos-FR and sinkingsugar and removed request for Kryptos-FR February 17, 2023 05:47
@guusw guusw self-assigned this Feb 17, 2023
src/core/runtime.cpp Outdated Show resolved Hide resolved
src/core/runtime.cpp Outdated Show resolved Hide resolved
src/core/runtime.hpp Outdated Show resolved Hide resolved
src/extra/gfx/drawable_utils.hpp Show resolved Hide resolved
@guusw guusw force-pushed the guus/pbr branch 2 times, most recently from 30a4ba5 to 3890f35 Compare February 21, 2023 03:49
@guusw guusw requested a review from sinkingsugar February 21, 2023 04:30
@@ -20,6 +22,10 @@ struct MainWindow final {
SHCCSTR("If the device backing the window should be created with "
"debug layers on."),
{CoreInfo::BoolType}},
{"IgnoreCompilationErrors",
SHCCSTR("When enabled, shader or pipeline compilation errors will be ignored and either use fallback rendering or not "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh 😐 can't compilation happen within Maybe shards?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean this is good for development but not sure needed.. can maybe.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep it I guess... 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's harder to do since it happens deeper within GFX.Render

src/core/runtime.cpp Outdated Show resolved Hide resolved
src/gfx/pmr/set.hpp Outdated Show resolved Hide resolved
guusw added 15 commits February 21, 2023 18:39
- Increase frame cleanup thresholds for pipelines/shaders
- Per view/drawable generator wires. Derive parameters
- Pass features to generators
- Instance render graph evaluator per render call
- Add writable frag_depth
- Fix captured variables inside generator wires
- Fix ViewData being captured during graph building (needs to be fully dynamic)

# Conflicts:
#	src/extra/gfx.cpp
#	src/gfx/render_graph.hpp
#	src/gfx/renderer.cpp
@guusw guusw merged commit 02415ae into devel Feb 22, 2023
@guusw guusw deleted the guus/pbr branch May 15, 2023 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants