-
Notifications
You must be signed in to change notification settings - Fork 174
GL: re-implement the RSP pipeline on top of magma #906
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
snacchus
wants to merge
1
commit into
DragonMinded:preview
Choose a base branch
from
snacchus:gl-magma-port
base: preview
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 all commits
Commits
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
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 |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| #ifndef __ARRAY_H | ||
| #define __ARRAY_H | ||
|
|
||
| #include <stdint.h> | ||
| #include "GL/gl.h" | ||
|
|
||
| typedef enum { | ||
| ARRAY_VERTEX, | ||
| ARRAY_NORMAL, | ||
| ARRAY_COLOR, | ||
| ARRAY_TEXCOORD, | ||
| ARRAY_MTX_INDEX, | ||
| ARRAY_COUNT | ||
| } array_type_t; | ||
|
|
||
| typedef struct gl_buffer_object_s gl_buffer_object_t; | ||
|
|
||
| typedef void (*cpu_read_attrib_func)(void*,const void*,uint32_t); | ||
| typedef void (*rsp_read_attrib_func)(void*,const void*,uint32_t); | ||
|
|
||
| typedef struct array_s { | ||
| GLint size; | ||
| GLenum type; | ||
| GLsizei stride; | ||
| const GLvoid *pointer; | ||
| gl_buffer_object_t *binding; | ||
| bool normalize; | ||
| bool enabled; | ||
|
|
||
| const GLvoid *final_pointer; | ||
| uint16_t final_stride; | ||
| cpu_read_attrib_func cpu_read_func; | ||
| rsp_read_attrib_func rsp_read_func; | ||
| } array_t; | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| inline uint32_t array_type_get_stride(array_type_t type) | ||
| { | ||
| switch (type) | ||
| { | ||
| case ARRAY_VERTEX: | ||
| return sizeof(int16_t) * 3; | ||
| case ARRAY_NORMAL: | ||
| return sizeof(uint16_t); | ||
| case ARRAY_COLOR: | ||
| return sizeof(uint32_t); | ||
| case ARRAY_TEXCOORD: | ||
| return sizeof(int16_t) * 2; | ||
| case ARRAY_MTX_INDEX: | ||
| return sizeof(uint8_t); | ||
| default: | ||
| return 0; | ||
| } | ||
| } | ||
|
|
||
| inline uint32_t array_type_get_alignment(array_type_t type) | ||
| { | ||
| switch (type) | ||
| { | ||
| case ARRAY_VERTEX: | ||
| return 8; | ||
| case ARRAY_NORMAL: | ||
| return 2; | ||
| case ARRAY_COLOR: | ||
| return 4; | ||
| case ARRAY_TEXCOORD: | ||
| return 4; | ||
| case ARRAY_MTX_INDEX: | ||
| default: | ||
| return 1; | ||
| } | ||
| } | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif | ||
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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #include "array_convert.h" | ||
|
|
||
| void array_convert(array_convert_parms_t *parms) | ||
| { | ||
| for (size_t i = 0; i < parms->range.count; i++) | ||
| { | ||
| for (size_t j = 0; j < parms->array_count; j++) | ||
| { | ||
| uint8_t *dst = ((uint8_t*)parms->out_buffer) + parms->out_layout->offsets[j] + i * parms->out_layout->stride; | ||
| const array_t *array = parms->arrays[j]; | ||
| const uint8_t *src = ((const uint8_t*)array->final_pointer) + (i+parms->range.first) * array->final_stride; | ||
| array->rsp_read_func(dst, src, array->size); | ||
| } | ||
| } | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #ifndef __ARRAY_CONVERT_H | ||
| #define __ARRAY_CONVERT_H | ||
|
|
||
| #include "indices.h" | ||
| #include "array.h" | ||
| #include "data_source.h" | ||
|
|
||
| typedef struct array_convert_parms_s { | ||
| const array_t *arrays[ARRAY_COUNT]; | ||
| uint32_t array_count; | ||
| const data_layout_t *out_layout; | ||
| index_bounds_t range; | ||
| void *out_buffer; | ||
| } array_convert_parms_t; | ||
|
Collaborator
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. I could use some documentation of this structure and how the various fields relate. |
||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| void array_convert(array_convert_parms_t *parms); | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif | ||
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.
missing extern inline