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

Use texture sampler in HLSL #72

Closed
DGriffin91 opened this issue Apr 12, 2024 · 1 comment · Fixed by #74
Closed

Use texture sampler in HLSL #72

DGriffin91 opened this issue Apr 12, 2024 · 1 comment · Fixed by #74
Assignees
Labels
enhancement New feature or request

Comments

@DGriffin91
Copy link
Contributor

When trying to sample a texture in hlsl I get an error from this:

_ => unimplemented!(),

With the enum vk::DescriptorType::Sampler

I'm setting the sampler for the fragment shader with: .image_sampler((0, 1), sampler)

struct FullscreenVertexOutput
{
    float4 position : SV_Position;
    [[vk::location(0)]]
    float2 uv : TEXCOORD0;
};

[[vk::binding(0, 0)]]
Texture2D screenTexture : register(t0);
[[vk::binding(1, 0)]]
SamplerState textureSampler : register(s0);
float4 main(FullscreenVertexOutput input)
    : SV_Target
{
    return screenTexture.Sample(textureSampler, input.uv);
}

This GLSL version using a combined sampler works as expected:

#version 450

layout(binding = 0) uniform sampler2D screenTexture;

layout(location = 0) in vec2 inUV;
layout(location = 0) out vec4 outColor;

void main() { outColor = texture(screenTexture, inUV); }

Are only combined sampler currently supported?
DXC appears to support [[vk::combinedImageSampler]], but shaderc does not: google/shaderc#1310

@DGriffin91 DGriffin91 changed the title Use texture sampler in hlsl Use texture sampler in HLSL Apr 14, 2024
@attackgoat attackgoat self-assigned this Apr 15, 2024
@attackgoat attackgoat added the enhancement New feature or request label Apr 15, 2024
@attackgoat attackgoat linked a pull request Apr 15, 2024 that will close this issue
@attackgoat
Copy link
Owner

Thanks for the detailed issue description and links! I added support to examples/image_sampler.rs showing how to use combined and separate samplers for both GLSL and HLSL.

This was a feature I haven't needed myself and so it was unimplemented. There may be more things like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants