Skip to content

DX12 support#2

Merged
mark-beiline merged 10 commits into
devfrom
mark/dx12
Dec 12, 2022
Merged

DX12 support#2
mark-beiline merged 10 commits into
devfrom
mark/dx12

Conversation

@mark-beiline
Copy link
Copy Markdown
Collaborator

No description provided.

@mark-beiline mark-beiline marked this pull request as ready for review December 5, 2022 22:10
Copy link
Copy Markdown
Owner

@wenzhang-unity wenzhang-unity left a comment

Choose a reason for hiding this comment

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

Overall looks pretty good. I have a couple of comments for you to look at 🙂

Comment thread .gitignore Outdated
.vs/

# Files built by Visual Studio
*_i.c
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can you specify a directory (or directories) for VS-generated files? Specifying individual files could become a maintenance headache. Also, you have *.pdb in here, which you may not want ignored, since I see you have a .pdb file added to the repo.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Created a .gitignore inside the ~Native directory to contain the VS rules
PDB deleted


NativeRenderingPlugin.PixelFormat ToNativeRenderingPluginFormat(RSPixelFormat rsPixelFormat)
{
switch (rsPixelFormat)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This would be a good spot to use a switch expression

NativeRenderingPlugin.PixelFormat ToNativeRenderingPluginFormat(RSPixelFormat rsPixelFormat) =>
    rsPixelFormat switch
    {
        RSPixelFormat.RS_FMT_BGRA8 => NativeRenderingPlugin.PixelFormat.BGRA8,
        RSPixelFormat.RS_FMT_BGRX8 => NativeRenderingPlugin.PixelFormat.BGRX8,
        // etc.
        _ => NativeRenderingPlugin.PixelFormat.BGRA8 // alternatively, you may want to throw ArgumentOutOfRange here instead
    }

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Couldn't throw the exception when using the pattern matching syntax, decided to keep the old syntax but added exception throwing for both switches

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

What do you mean? You can certainly throw exceptions in switch expressions.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Using a throw statement with the nicer syntax gave me syntax errors, the compiler wouldn't allow ex:

NativeRenderingPlugin.PixelFormat ToNativeRenderingPluginFormat(RSPixelFormat rsPixelFormat) =>
    rsPixelFormat switch
    {
        RSPixelFormat.RS_FMT_BGRA8 => NativeRenderingPlugin.PixelFormat.BGRA8,
        RSPixelFormat.RS_FMT_BGRX8 => NativeRenderingPlugin.PixelFormat.BGRX8,
        // etc.
        _ => throw new ArgumentOutOfRange()
    }

It's why I went with the old case X: return Y and default: throw ... syntax.

Comment thread DisguiseUnityRenderStream/Runtime/FrameSender.cs Outdated
m_streamHandle = 0;
}

Texture2D CreateTextureForDisguise(int width, int height, RSPixelFormat format)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Consider moving CreateTextureForDisguise and ResizeTextureForDisguise to a helper class. They can also be made static.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Moved to DisguiseTextures.cs

Comment thread DisguiseUnityRenderStream/Runtime/PluginEntry.cs Outdated
Comment thread Native~/DX12System.h Outdated
Comment thread Native~/DX12Texture.h Outdated
Comment thread Native~/Logger.h Outdated
Comment thread Native~/main.cpp
Comment thread Native~/Utility.h Outdated
Copy link
Copy Markdown
Owner

@wenzhang-unity wenzhang-unity left a comment

Choose a reason for hiding this comment

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

Just a minor thing. The rest looks good.

Comment thread Native~/Logger.h
@wenzhang-unity
Copy link
Copy Markdown
Owner

Feel free to merge it when you're ready.

@mark-beiline mark-beiline merged commit f4e11c3 into dev Dec 12, 2022
@mark-beiline mark-beiline deleted the mark/dx12 branch January 12, 2023 18:36
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