-
Notifications
You must be signed in to change notification settings - Fork 167
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
Introduce batching engine and shadow batching #847
Open
aglab2
wants to merge
5
commits into
HackerN64:develop/3.0.0
Choose a base branch
from
aglab2:shadow-batching-v2
base: develop/3.0.0
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
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d1698e9
Introduce batching engine and shadow batching
aglab2 9c49eaa
Rename batch ids for easier readability
aglab2 1c69014
Fixed various nits in shadow batching
aglab2 582d17e
Introduce static asserts to ensure all constant batches are set
aglab2 4b780f9
Fixed incorrect const batches names
aglab2 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 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 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 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "batch_list.h" | ||
|
||
#include "game/segment2.h" | ||
|
||
static inline struct BatchArray* batch_array_alloc(struct AllocOnlyPool *pool, int count) | ||
{ | ||
struct BatchArray* batches = alloc_only_pool_alloc(pool, sizeof(struct BatchArray) + count * sizeof(struct Batch)); | ||
batches->count = count; | ||
return batches; | ||
} | ||
|
||
static inline void batch_setup(struct BatchArray* arr, int idx, const void* start, const void* end) | ||
{ | ||
struct Batch* batch = &arr->batches[idx]; | ||
batch->startDl = start; | ||
batch->endDl = end; | ||
} | ||
|
||
struct BatchArray* batch_list_objects_alloc_xlu_decal(struct AllocOnlyPool *pool) | ||
{ | ||
struct BatchArray* arr = batch_array_alloc(pool, BATCH_TRANSPARENT_DECAL_COUNT); | ||
batch_setup(arr, BATCH_TRANSPARENT_DECAL_SHADOW_CIRCLE, dl_shadow_circle, dl_shadow_end); | ||
batch_setup(arr, BATCH_TRANSPARENT_DECAL_SHADOW_SQUARE, dl_shadow_square, dl_shadow_end); | ||
return arr; | ||
} | ||
|
||
struct BatchArray* batch_list_objects_alloc_cld(struct AllocOnlyPool *pool) | ||
{ | ||
struct BatchArray* arr = batch_array_alloc(pool, BATCH_CLD_COUNT); | ||
batch_setup(arr, BATCH_CLD_SHADOW_CIRCLE, dl_shadow_circle, dl_shadow_end); | ||
batch_setup(arr, BATCH_CLD_SHADOW_SQUARE, dl_shadow_square, dl_shadow_end); | ||
return arr; | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include "sm64.h" | ||
#include "engine/graph_node.h" | ||
|
||
struct BatchArray* batch_list_objects_alloc_xlu_decal(struct AllocOnlyPool *pool); | ||
struct BatchArray* batch_list_objects_alloc_cld(struct AllocOnlyPool *pool); | ||
|
||
static inline struct BatchArray* batch_list_objects_alloc(struct AllocOnlyPool *pool, enum RenderLayers layer) | ||
gheskett marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
switch (layer) | ||
{ | ||
case LAYER_TRANSPARENT_DECAL: | ||
return batch_list_objects_alloc_xlu_decal(pool); | ||
case LAYER_CLD: | ||
return batch_list_objects_alloc_cld(pool); | ||
default: | ||
return 0; | ||
} | ||
} |
This file contains 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 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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idk how I feel about this, what does the 4 actually represent here, number of coin textures? If so, that should be defined somewhere, ideally automatically computed or enforced with a static assert if possible.
Ditto for the flames.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the easiest solution is to add a static assert.
sm64.h
is a glue between subsystems geo->layer->batches->dls. It would be hard to deduce amount of coin textures without including actors in sm64.h which is not something I want to do.For now I will remove those enums because they are unused anyways and reland them later with batching for specific objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have provided the static asserts for constant batches, it actually appeared to be pretty easy to implement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could these be moved to
batch_list.h
? Idk if they make the most sense insm64.h
anyway, though to be fair the layer definitions are also here...