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

Bootstrap/dx11 debug shapes #4

Merged
merged 10 commits into from
Jun 27, 2023
Merged

Bootstrap/dx11 debug shapes #4

merged 10 commits into from
Jun 27, 2023

Conversation

Condzi
Copy link
Owner

@Condzi Condzi commented Jun 25, 2023

No description provided.

Comment on lines 2 to 3
row_major float4x4 transform;
row_major float4x4 projection;

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.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done



vs_out vs_main(vs_in input) {
vs_out output = (vs_out)0; // zero the memory first

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.

Copy link
Owner Author

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 {

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
Comment on lines 3 to 6
::ID3D11Device *device = NULL;
::ID3D11DeviceContext *device_context = NULL;
::IDXGISwapChain *swap_chain = NULL;
::ID3D11RenderTargetView *render_target_view = NULL;

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).

Copy link
Owner Author

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;

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.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done

Comment on lines +231 to +236
::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
};

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.

Copy link
Owner Author

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.

@Condzi Condzi merged commit 020d3cd into develop Jun 27, 2023
@Condzi Condzi deleted the bootstrap/dx11-debug-shapes branch June 27, 2023 18:26
Condzi added a commit that referenced this pull request Jun 29, 2023
* 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
Condzi added a commit that referenced this pull request Jul 8, 2023
* 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
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