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

VideoBackends / VideoCommon: expose ability to view shader/texture debug names #10065

Merged
merged 1 commit into from Aug 30, 2021

Conversation

iwubcode
Copy link
Contributor

This gives the ability to view an application defined name for our Shaders/Textures in applications like RenderDoc. Currently nothing takes advantage of this but a future feature will. Breaking it out to make it easier to review.

@iwubcode
Copy link
Contributor Author

iwubcode commented Aug 29, 2021

I fixed most of the lint errors but the last error isn't matching my local formatting (I tried both clang-format 12.0.0 and 12.0.1).

@leoetlino
Copy link
Member

I fixed most of the lint errors but the last error isn't matching my local formatting (I tried both clang-format 12.0.0 and 12.0.1).

Are you using Visual Studio's bundled copy of clang-format? If so, we should probably update our required clang-format version to 12...

@iwubcode
Copy link
Contributor Author

iwubcode commented Aug 29, 2021

Are you using Visual Studio's bundled copy of clang-format? If so, we should probably update our required clang-format version to 12...

Yeah I'm using VS bundled clang-format which is 12.0.0. I thought maybe it was out of date so I grabbed the latest (12.0.1) from the prebuilt llvm release. I didn't think about the buildbot version being too old!

Copy link
Member

@leoetlino leoetlino left a comment

Choose a reason for hiding this comment

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

Reviewed 32 of 32 files at r1, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @iwubcode)


Source/Core/VideoBackends/D3D/DXShader.h, line 7 at r1 (raw file):

#include <memory>
#include <optional>

<optional> seems to be unused


Source/Core/VideoBackends/D3D/DXShader.cpp, line 16 at r1 (raw file):

  if (!name.empty())
  {
    m_shader->SetPrivateData(WKPDID_D3DDebugObjectName, static_cast<UINT>(name.size()),

For anyone wondering, SetPrivateData performs a copy of the string so there are no lifetime issues here.


Source/Core/VideoBackends/D3D/DXTexture.cpp, line 20 at r1 (raw file):

DXTexture::DXTexture(const TextureConfig& config, ComPtr<ID3D11Texture2D> texture,
                     std::string_view name)
    : AbstractTexture(config), m_texture(std::move(texture)), m_name(name)

Just wondering, why do we need to store the name in this class (DXTexture) and not in DXShader?

Come to think of it, does SetPrivateData require that the name is null-terminated? If so, DXShader would have to store the name in a std::string to make sure it is null-terminated.


Source/Core/VideoBackends/OGL/OGLShader.h, line 20 at r1 (raw file):

public:
  explicit OGLShader(ShaderStage stage, GLenum gl_type, GLuint gl_id, std::string source,
                     std::string name);

#include <string>


Source/Core/VideoBackends/Software/SWRenderer.h, line 24 at r1 (raw file):

  std::unique_ptr<AbstractTexture> CreateTexture(const TextureConfig& config,
                                                 std::string_view name) override;

missing include for string_view


Source/Core/VideoBackends/Vulkan/VKRenderer.h, line 39 at r1 (raw file):

  std::unique_ptr<AbstractTexture> CreateTexture(const TextureConfig& config,
                                                 std::string_view name) override;

include


Source/Core/VideoBackends/Vulkan/VKShader.cpp, line 63 at r1 (raw file):
According to Vulkan docs:

VUID-VkDebugUtilsObjectNameInfoEXT-pObjectName-parameter

If pObjectName is not NULL, pObjectName must be a null-terminated UTF-8 string

So it seems you need a std::string to ensure the name is null-terminated. The docs aren't clear about the required lifetime for the string you pass in though...

@iwubcode iwubcode force-pushed the graphics-debug-details branch 2 times, most recently from ad0cfd5 to e1fbba5 Compare August 30, 2021 05:12
@iwubcode
Copy link
Contributor Author

iwubcode commented Aug 30, 2021

Thank you @leoetlino for reviewing! I'll admit, I didn't find a majority of the graphics api documentation very clear about lifetime requirements which is why I opted for the design I did. Unfortunately, I guess I wasn't very thorough, so thank you for catching the issues you did :) You were right about the null termination, I fixed up the apis to be consistent.

Copy link
Member

@leoetlino leoetlino left a comment

Choose a reason for hiding this comment

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

Reviewed 7 of 7 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @iwubcode)


Source/Core/VideoBackends/Vulkan/VKShader.cpp, line 21 at r2 (raw file):

  if (!m_name.empty())
  {
    VkDebugUtilsObjectNameInfoEXT nameInfo = {};

name_info


Source/Core/VideoBackends/Vulkan/VKShader.cpp, line 36 at r2 (raw file):

  if (!m_name.empty())
  {
    VkDebugUtilsObjectNameInfoEXT nameInfo = {};

name_info

@leoetlino
Copy link
Member

Rebasing should fix the lint failure

… shaders / textures. These names are visible in applications like RenderDoc
Copy link
Member

@leoetlino leoetlino left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @iwubcode)

@leoetlino leoetlino merged commit d94aa91 into dolphin-emu:master Aug 30, 2021
11 checks passed
@iwubcode iwubcode deleted the graphics-debug-details branch August 31, 2021 02:00
@iwubcode
Copy link
Contributor Author

Thanks @leoetlino for reviewing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants