-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Backends: DX9: add programmable rendering pipeline implementation #3874
base: master
Are you sure you want to change the base?
Conversation
Thanks for the cleaned up PR and explanation!
I am very surprised the fps is so low. Are you running on a very old computer? I would expect to get 1000+ fps on most machines. Printing to system console is slow you can remove this before checking the framerate.
|
65536 white rects & Intel integrated graphics card (awesome), cause low fps. |
e662ed4
to
7716489
Compare
dfecb73
to
7229327
Compare
7229327
to
c813210
Compare
c813210
to
e9e77fb
Compare
0c1e5bd
to
bb6a60b
Compare
e9e77fb
to
31ad115
Compare
Reorganized the code. However, some duplicate codes have also been generated, and I am still thinking about how to solve it. |
8b83e0a
to
d735066
Compare
b3b85d8
to
0755767
Compare
c817acb
to
8d39063
Compare
bd21d4f
to
717adfa
Compare
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.
Hello,
As you intuited, I'm not yet sure this can be merged because it seems rather esoteric, but I am glad this exist and I would encourage to further tweak it. The suggestions I posted here are to facilitate the likehood of merging.
@@ -46,6 +46,11 @@ struct ImGui_ImplDX9_Data | |||
int VertexBufferSize; | |||
int IndexBufferSize; | |||
|
|||
IDirect3DVertexDeclaration9* pInputLayout; |
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.
Suggesting to add a comment at the top of those 4 fields, e.g. // Support for Shader Pipeline mode (rare)
.
Move the bool
at the top of this 4 variables block.
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 moved the variable position and added comments. It may be surprising that the number of devices supporting shader model 2 is very large, so I didn't use (rare), this should be acceptable.
backends/imgui_impl_dx9.cpp
Outdated
// HLSL source code | ||
/* | ||
float4x4 mvp : register(c0); | ||
|
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.
Suggest compacting the source code a little, remove empty lines, compact structures into one-liner.
The reasoning is to make this "optional" feature of DX9 backend not takes too much visibility in the source file, making it more likely to be mergeable.
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.
ok, I deleted redundant empty lines
backends/imgui_impl_dx9.cpp
Outdated
CODE(43,54,41,42), | ||
CODE(1C,00,00,00), | ||
CODE(4B,00,00,00), | ||
CODE(00,02,FE,FF), |
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.
Suggest removing the macros and using raw 0xXX data, with 16-bytes per lines. This will reduce the line count by 4 and remove a subtle layer of complexity.
CODE(00,02,FE,FF),
CODE(FE,FF,1E,00),
CODE(43,54,41,42),
CODE(1C,00,00,00),
into
0x00, 0x02, 0xFE, 0xFF, 0xFE, 0xFF, 0x1E, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1C, 0x00, 0x00, 0x00,
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.
Suggest adding a comment with an explicit command-line to turn the shader source into binary data.
I realize that MAYBE the output of that compiler is to output CODE(XX,XX,XX,XX)
but as it is unlikely to be rebuild (our other shaders have stayed stables for many years) this is mostly as reference.
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 finally decided to put them on the same line, and do not use hex, this helps reduce the number of source code characters (hex requires at least 3 characters, while decimal requires at least only 1)
backends/imgui_impl_dx9.cpp
Outdated
|
||
IDirect3DDevice9* ctx = bd->pd3dDevice; | ||
|
||
// Setup orthographic projection matrix |
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 this function call regular ImGui_ImplDX9_SetRenderState()
and then add the extra stuff afterwise?
backends/imgui_impl_dx9.cpp
Outdated
@@ -143,6 +577,9 @@ static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data) | |||
// Render function. | |||
void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data) | |||
{ | |||
if (ImGui_ImplDX9_Shader_RenderDrawData(draw_data)) | |||
return; | |||
|
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 bd->IsShaderPipeline
test can be performed here, and the sub-function asserts on that value. Makes the flow more obvious.
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.
This is really better. I have modified it
d83a52c
to
702e1d5
Compare
702e1d5
to
86e5977
Compare
86e5977
to
fc8094e
Compare
fc8094e
to
a093e5a
Compare
a093e5a
to
1424f6b
Compare
Before
The old pull request #3844 is too messy, so I create a new pr to discuss.
I think this pull request won't be merged for a long time:
Thanks to @ocornut, bring us such an excellent GUI library 👍.
Why?
So why did I put so much effort into writing this implementation?
#define IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT struct { ImVec2 pos; float z; ImVec2 uv; ImU32 col; };
, but what about z? Can we ignore it whatever it is? Ok, we will also need to setup our custom MemAlloc and MemFree, but this is not very elegant.Features
Test
Test code:
Build on Release config, running result:
For those who need this...
You are free to merge this pr into your own fork. This implementation is already working on our old devices, although I didn't do a whole lot of testing.
But, anyway, I don't guarantee it's bug-free. If you have any questions, feel free to leave a comment.