-
Notifications
You must be signed in to change notification settings - Fork 0
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
Bootstrap/dx11 debug shapes #4
Conversation
run_tree/data/shaders/shaders.hlsl
Outdated
row_major float4x4 transform; | ||
row_major float4x4 projection; |
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.
row_major is less efficient, prefer default one (column major). This change will require transposing matrixes before passing them to GPU.
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.
Done
run_tree/data/shaders/shaders.hlsl
Outdated
|
||
|
||
vs_out vs_main(vs_in input) { | ||
vs_out output = (vs_out)0; // zero the memory first |
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.
No need to zero-out the memory, C/C++ packing rules don't apply here and compiler will strip out this anyway.
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.
Done
return output; | ||
} | ||
|
||
float4 ps_main(vs_out input) : SV_TARGET { |
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.
SV_POSITION will be unused here, tend to prefer smallest needed set of data than the whole structure.
code/gfx/gfx.cpp
Outdated
::ID3D11Device *device = NULL; | ||
::ID3D11DeviceContext *device_context = NULL; | ||
::IDXGISwapChain *swap_chain = NULL; | ||
::ID3D11RenderTargetView *render_target_view = NULL; |
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.
Consider creating typedefs of ID3D types, ex. typedef ID3D11Device IDevice
to avoid interface versioning. D3D have various updates with increasing numbers as sufixes (from previous example, newest device is ID3D11Device5
from d3d11_4.h) to help in maintaining code. Also consider using COM smart pointers to avoid memory leaks and manual managment of interface counters (Microsoft way of handling lifetime of the interface).
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.
Done
flags |= D3D11_CREATE_DEVICE_DEBUG; | ||
#endif | ||
|
||
::D3D_FEATURE_LEVEL feature_level; |
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.
On all current hardware you can set to 11_1.
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.
Done
::D3D11_BUFFER_DESC const vbo_desc = { | ||
.ByteWidth = sizeof(XXC_Pipeline::v), | ||
.Usage = D3D11_USAGE_DYNAMIC, | ||
.BindFlags = D3D11_BIND_VERTEX_BUFFER, | ||
.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE | ||
}; |
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.
It is better to create D3D11_USAGE_IMMUTABLE resource and pass it an D3D11_SUBRESOURCE_DATA with initial data for vertex/index buffers to ensure they will end up in VRAM. This way you don't need any CPU access rights.
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 can't do it since the idea of this code is a pipeline for immediate-mode debug shapes - so they're updated every frame -> content of the buffer changes every frame.
* Bootstrap/basics (#2) * logf, check_, dbg_check_ * temp and perm memory * add errf * Baisc error handling, os_read_entire_file * Move OS to own folder * More file manipulation functions * minor style stuff * Update the docs with official information * Test String_Builder declaration * String_Builder * os_get_app_uptime_as_string * Delete log.txt * exception handler w.i.p * Fix compilation errors * Debugging functions * Tidy up OS code * add pathf * more pathf stuff * to_string -> to_temp_string * move code to base/ * notes * vector math * Matrix math for 2D * print cppcheck version in pipeline * notes * continue on error for cppcheck * Bootstrap/window (#3) * Window module declaration * add window procs * add a note * Bootstrap/dx11 debug shapes (#4) * Draft of renderer interface * DirectX devices init * Immediate mode pipeline * enable debug mode in DX11 * Cool shapes * column_major for constants * No need to zero the vs_out * Use typedefs for ID3D types * Request D3D 11.1 * formatting * add ImGui source * Extract the relevant backend files * imgui integrated * ignore 3rdparty code in cppcheck
* Bootstrap/basics (#2) * logf, check_, dbg_check_ * temp and perm memory * add errf * Baisc error handling, os_read_entire_file * Move OS to own folder * More file manipulation functions * minor style stuff * Update the docs with official information * Test String_Builder declaration * String_Builder * os_get_app_uptime_as_string * Delete log.txt * exception handler w.i.p * Fix compilation errors * Debugging functions * Tidy up OS code * add pathf * more pathf stuff * to_string -> to_temp_string * move code to base/ * notes * vector math * Matrix math for 2D * print cppcheck version in pipeline * notes * continue on error for cppcheck * Bootstrap/window (#3) * Window module declaration * add window procs * add a note * Bootstrap/dx11 debug shapes (#4) * Draft of renderer interface * DirectX devices init * Immediate mode pipeline * enable debug mode in DX11 * Cool shapes * column_major for constants * No need to zero the vs_out * Use typedefs for ID3D types * Request D3D 11.1 * formatting * Bootstrap/dear imgui integration (#7) * add ImGui source * Extract the relevant backend files * imgui integrated * ignore 3rdparty code in cppcheck
No description provided.