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

Scale retro terminal scan lines #4716

Merged
9 commits merged into from
Feb 26, 2020
Merged

Scale retro terminal scan lines #4716

9 commits merged into from
Feb 26, 2020

Conversation

dotpaul
Copy link
Contributor

@dotpaul dotpaul commented Feb 25, 2020

Summary of the Pull Request

Before & after, with my display scale set to 350%:
Scaling scan lines

Before & after showing artifact removal, with my display scale set to 100%, and image enlarged to 400%:
Sampling artifacts annotated

PR Checklist

  • Closes Retro terminal effect prodces artifacts on the right screen edge #4362
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Requires documentation to be updated
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

Detailed Description of the Pull Request / Additional comments

Adds a constant buffer, which could be used for other settings for the retro terminal pixel shader.

I haven't touched C++ in over a decade before this change, and this is the first time I've played with DirectX, so please assume my code isn't exactly best practice. 🙂

Validation Steps Performed

  • Changed display scale with experimental.retroTerminalEffect enabled, enjoyed scan lines on high resolution monitors.
  • Enabled experimental.retroTerminalEffect, turned the setting off, changed display scale. Retro tabs still scale scan lines.

@DHowett-MSFT
Copy link
Contributor

YES THANK YOU

@DHowett-MSFT
Copy link
Contributor

You can add Closes #4362 for the screen edge issue

@dotpaul
Copy link
Contributor Author

dotpaul commented Feb 25, 2020

You're welcome! Tagged the screen edge issue.

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

Yea I'm cool with this, even if I don't totally understand what that sizeof math is doing.

@@ -285,12 +285,24 @@ HRESULT DxEngine::_SetupTerminalEffects()

RETURN_IF_FAILED(_d3dDevice->CreateBuffer(&bd, &InitData, &_screenQuadVertexBuffer));

D3D11_BUFFER_DESC pixelShaderSettingsBufferDesc{};
pixelShaderSettingsBufferDesc.Usage = D3D11_USAGE_DEFAULT;
pixelShaderSettingsBufferDesc.ByteWidth = sizeof(_pixelShaderSettings) + (16 - sizeof(_pixelShaderSettings) % 16) % 16;
Copy link
Member

Choose a reason for hiding this comment

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

Okay I don't know DX that well but what the heck is going on here

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this is "nearest larger multiple of 16"

libra  ~  %   $n=9
libra  ~  %   $n + (16 - $n % 16) % 16
16
libra  ~  %   $n=17
libra  ~  %   $n + (16 - $n % 16) % 16
32

Copy link
Contributor

Choose a reason for hiding this comment

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

(that "multiples of 16" thing is documented in the docs for CreateBuffer for when you pass D3D11_BIND_CONSTANT_BUFFER)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. Thinking about this more, I want to pad the struct instead. As it is now, I would assume DirectX is reading beyond the struct's memory when initializing / updating the constant buffer, which would make me feel bad.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing that out, @zadjii-msft !

samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
Copy link
Member

Choose a reason for hiding this comment

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

THANK YOU

@zadjii-msft
Copy link
Member

@msftbot make sure @miniksa signs off on this

@ghost ghost added the AutoMerge Marked for automatic merge by the bot when requirements are met label Feb 25, 2020
@ghost
Copy link

ghost commented Feb 25, 2020

Hello @zadjii-msft!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I'll only merge this pull request if it's approved by @miniksa

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

@zadjii-msft zadjii-msft added Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Product-Terminal The new Windows Terminal. labels Feb 25, 2020
@@ -285,12 +285,24 @@ HRESULT DxEngine::_SetupTerminalEffects()

RETURN_IF_FAILED(_d3dDevice->CreateBuffer(&bd, &InitData, &_screenQuadVertexBuffer));

D3D11_BUFFER_DESC pixelShaderSettingsBufferDesc{};
pixelShaderSettingsBufferDesc.Usage = D3D11_USAGE_DEFAULT;
pixelShaderSettingsBufferDesc.ByteWidth = sizeof(_pixelShaderSettings) + (16 - sizeof(_pixelShaderSettings) % 16) % 16;
Copy link
Contributor

Choose a reason for hiding this comment

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

(that "multiples of 16" thing is documented in the docs for CreateBuffer for when you pass D3D11_BIND_CONSTANT_BUFFER)

src/renderer/dx/DxRenderer.cpp Show resolved Hide resolved
@ghost ghost added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Feb 25, 2020
@ghost ghost removed the AutoMerge Marked for automatic merge by the bot when requirements are met label Feb 25, 2020
@DHowett-MSFT
Copy link
Contributor

@msftbot make sure @miniksa signs off

@ghost ghost added the AutoMerge Marked for automatic merge by the bot when requirements are met label Feb 25, 2020
@ghost
Copy link

ghost commented Feb 25, 2020

Hello @DHowett-MSFT!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I'll only merge this pull request if it's approved by @miniksa

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

Copy link
Contributor

@DHowett-MSFT DHowett-MSFT left a comment

Choose a reason for hiding this comment

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

I'm flipping the sense on my approval bit because I learned that the HRESULT thing isn't actually true.

## Summary of the Pull Request

I needed to do something to keep sane so today I day of learned about antialiasing. This PR adds the ability to specify the `"antialiasingMode"` as a setting.
* "antialiasingMode": "grayscale": the current behavior, `D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE`
* "antialiasingMode": "cleartype": use `D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE` instead


## PR Checklist
* [x] Closes microsoft#1298
* [x] I work here
* [ ] I didn't add tests 
* [x] Requires documentation to be updated

## Detailed Description of the Pull Request / Additional comments
Grayscale:
 
![image](https://user-images.githubusercontent.com/18356694/75173847-2373f680-56f5-11ea-8896-c1cf04c61d41.png)



Cleartype:
![image](https://user-images.githubusercontent.com/18356694/75173854-25d65080-56f5-11ea-9de1-e2d1c343cae5.png)

 


Side-by-side (can you tell which is which?) <!-- grayscale, cleartype -->
 
![image](https://user-images.githubusercontent.com/18356694/75173864-28d14100-56f5-11ea-8bdd-d47a60fbbe4d.png)
@@ -74,7 +78,7 @@ float4 main(float4 pos : SV_POSITION, float2 tex : TEXCOORD) : SV_TARGET

// TODO:GH#3930 Make these configurable in some way.
Copy link
Member

Choose a reason for hiding this comment

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

Well this TODO is going to be a lot easier now that you piped through the settings buffer.

Copy link
Member

@miniksa miniksa left a comment

Choose a reason for hiding this comment

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

Wonderful, thank you.

@DHowett-MSFT
Copy link
Contributor

I pushed a merge to your branch so we could land it 😄

@dotpaul
Copy link
Contributor Author

dotpaul commented Feb 25, 2020

I pushed a merge to your branch so we could land it 😄

Ah, thank you @DHowett-MSFT !

@ghost ghost merged commit de5e72f into microsoft:master Feb 26, 2020
@dotpaul dotpaul deleted the scaleScanLines branch February 26, 2020 19:50
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues AutoMerge Marked for automatic merge by the bot when requirements are met Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Retro terminal effect prodces artifacts on the right screen edge
5 participants