-
Notifications
You must be signed in to change notification settings - Fork 79
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
DX11 Graphics Backend #50
Open
matthewgeorgy
wants to merge
53
commits into
MrFrenik:master
Choose a base branch
from
matthewgeorgy:dx11_backend
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
Conversation
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
Still lots of things to add, even to the simple things so far. See comments for more details.
- Refacted to use D3D11's C interface
…why it's broken in gs_dx11.h.
…ill break the GS handle system (it won't, talked about it with John and it turns out I was just confused + misreading)
…ts to DX11 formats. - Added few comments documenting future ideas
…set. - Added function for creating index buffers (index_buffer_create) - Resolved compiler errors.
- Added main.c; successfully drawing red triangle! (many steps skipped..., too many d3d11 calls)
- Now creating shaders through impl instead of directly through dx11!
…command buffer system - Tested and verified clearing these buffers through a command buffer
- Tested and verified changing viewport size this way (commented out in main.c)
…the command buffer system
…urces (VS + PS) - Verified with main.c - Need this change for implementing pipeline bindings because the raster_state_desc only supports binding a single shader at a time. Thus, we need to group all of our shaders into a single handle + struct so that they can be sent to the pipeline, and then from that point we can bind them each individually with {}SSetShader.
- Tested + verified in main.c
- Now able to find vertex buffers to the pipeline - Tested/verified in main.c
…INGS op. This is perfectly legal we require the pipeline to be bound before we can bind any additional data. This is not stated explicitly (AFAIK), but it makes sense, especially if you look at the GL impl, which does the same thing. - Left original comments for OP_DRAW since some comments need be addressed in the future (such as strides, offsets, etc.) - Also removed the commented-out IASetVertexBuffers() call in main.c for cleanliness
- Tested in main.c; removed input layout stuff in main.c
- Tested in main.c
… required by the actual implementation
- Currently, the create function is working, and binding the buffer is handled as a case in apply_bindings. - Now, this case must be dealt with in the APPLY_BINDINGS op
- Removed assertion for uniform buffer desc having a name
- Made changes in main.c/data.c for this to use the DX11 backend - Need to test and debug (currently getting a white screen, but no crashes?)
…e buffer - Used some mho_math mat4 funcs instead of gs' in main.c - Successfully rotating the red cube! Although, for some reason it's shifted to the right instead of the left, need to figure out why. - Next is to implement multiple render passes so that we can draw all 4 colored cubes at once
- Added error handling in shader_create(... ) in case of failed compilation
…r now - Next to implement are uniforms, as these will act as resource views for textures (and maybe buffers in the future if GS starts supporting it)
- Still needs to be tested and verified
…ng for Texture2D's - Added functionality for reading multiple subbuffers from the pipeline layout in OP_APPLY_BINDINGS - Added main.c test program for uniform/texture creation + binding - Tested and verified!
…using previous buffer data to be invalidated
…ead}|{write} perms + dynamic buffer usage
…riptors (see big comment). - Need to also handle INDEXED instanced rendering (shouldn't be hard).
- Removed the 'instanced' field in the cache since it's redundant
…n build simple_triangle and index_buffer examples with the scheme I've developed currently. - Next step is to port the remaining command buffer parts to use the command list and test to make sure that more of the example apps work.
- Updated vertex buffer binding logic to support instanced (+ indexed) rendering in the command list scheme
- Handling uniform buffer update requests with command lists
- Cleaned up (aka removed) most of the legacy command buffer stuff, might have some more left to remove
- Implemented object creation thread-safety with CRITICAL_SECTION objects
- Cleaned up some stuff + comment about testing the thread-safety mechanisms
This reverts commit 2bfe44c. fixing state
matthewgeorgy
force-pushed
the
dx11_backend
branch
from
August 19, 2022 13:34
d5c187b
to
aa196d5
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Figured I'd put it in a separate branch to make tracking its progress easier.
Currently, only a few things have been implemented thus far, but the plumbing is laid out for many more things to be added in the future. To get an idea of how much is implemented, I can compile and run the
02_simple_triangle
,04_simple_texture
,07_instancing
(with and without index buffers), and19_uniform_buffer
.Implemented so far
Resource creation:
gs_graphics_vertex_buffer_create(...)
gs_graphics_index_buffer_create(...)
gs_graphics_shader_create(...)
gs_graphics_pipeline_create(...)
gs_graphics_uniform_buffer_create(...)
gs_graphics_uniform_create(...)
gs_graphics_texture_create(...)
(+ internal())Resource Updates:
__gs_graphics_update_buffer_internal(...)
gs_graphics_uniform_buffer_update_request(...)
Command Buffer Ops:OP_BEGIN_RENDER_PASS
OP_END_RENDER_PASS
OP_SET_VIEWPORT
OP_CLEAR
OP_BIND_PIPELINE
OP_APPLY_BINDINGS
OP_DRAW
Scrapped the command buffer + op code system in favour for
ID3D11CommandList
s.Supported features:
Command Buffer Funcs:
gs_graphics_begin_render_pass(...)
gs_graphics_end_render_pass(...)
gs_graphics_clear(...)
gs_graphics_set_viewport(...)
gs_graphics_apply_bindings(...)
gs_graphics_bind_pipeline(...)
gs_graphics_draw(...)
gs_graphics_submit_command_buffer(...)
The command buffer system works by first receiving thegs_graphics_pipeline
object with the call togs_graphics_bind_pipeline
, binding shaders, and then caching it for later use. Then, using this cached pipeline, vertex buffer layouts are filled in under theOP_APPLY_BINDINGS
instruction. Here, any appropriate vertex buffers are bound, and theID3D11InputLayout
is created here and also bound. The only purpose of theOP_DRAW
instruction is to make the API draw call, using all of the data that was bound to the pipeline by the previous two instructions.This is different from the OpenGL implementation, where the
OP_DRAW
instruction is also responsible for binding some necessary data. This is the design choice for now but, of course, it may change in the future.NOTE: I have completely revamped the command buffer system by getting rid of it and using
ID3D11CommandList
and deferred contexts in order to support proper multithreaded rendering safety. I've also made use ofCRITICAL_SECTION
objects to allow for safe multithreaded object creation.
Next Steps
ID3D11CommandList
+ deferred contextMy main testing philosophy is to get as many of the example apps running with this backend as possible. This also doubles as a simple way of tracking progress and figuring out what needs to be implemented next.