Add a GetDefaultSamplerDescriptor helper.
This commit is contained in:
parent
5101d57972
commit
b711b9b2c9
|
@ -56,16 +56,8 @@ void initTextures() {
|
||||||
.SetAllowedUsage(nxt::TextureUsageBit::TransferDst | nxt::TextureUsageBit::Sampled)
|
.SetAllowedUsage(nxt::TextureUsageBit::TransferDst | nxt::TextureUsageBit::Sampled)
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
{
|
nxt::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
|
||||||
nxt::SamplerDescriptor desc;
|
sampler = device.CreateSampler(&samplerDesc);
|
||||||
desc.minFilter = nxt::FilterMode::Linear;
|
|
||||||
desc.magFilter = nxt::FilterMode::Linear;
|
|
||||||
desc.mipmapFilter = nxt::FilterMode::Linear;
|
|
||||||
desc.addressModeU = nxt::AddressMode::Repeat;
|
|
||||||
desc.addressModeV = nxt::AddressMode::Repeat;
|
|
||||||
desc.addressModeW = nxt::AddressMode::Repeat;
|
|
||||||
sampler = device.CreateSampler(&desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize the texture with arbitrary data until we can load images
|
// Initialize the texture with arbitrary data until we can load images
|
||||||
std::vector<uint8_t> data(4 * 1024 * 1024, 0);
|
std::vector<uint8_t> data(4 * 1024 * 1024, 0);
|
||||||
|
|
|
@ -64,16 +64,8 @@ void initTextures() {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
renderTargetView = renderTarget.CreateTextureViewBuilder().GetResult();
|
renderTargetView = renderTarget.CreateTextureViewBuilder().GetResult();
|
||||||
|
|
||||||
{
|
nxt::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
|
||||||
nxt::SamplerDescriptor desc;
|
samplerPost = device.CreateSampler(&samplerDesc);
|
||||||
desc.minFilter = nxt::FilterMode::Linear;
|
|
||||||
desc.magFilter = nxt::FilterMode::Linear;
|
|
||||||
desc.mipmapFilter = nxt::FilterMode::Linear;
|
|
||||||
desc.addressModeU = nxt::AddressMode::Repeat;
|
|
||||||
desc.addressModeV = nxt::AddressMode::Repeat;
|
|
||||||
desc.addressModeW = nxt::AddressMode::Repeat;
|
|
||||||
samplerPost = device.CreateSampler(&desc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void initPipeline() {
|
void initPipeline() {
|
||||||
|
|
|
@ -336,14 +336,8 @@ namespace {
|
||||||
const auto& iSamplerID = s.first;
|
const auto& iSamplerID = s.first;
|
||||||
const auto& iSampler = s.second;
|
const auto& iSampler = s.second;
|
||||||
|
|
||||||
nxt::SamplerDescriptor desc;
|
nxt::SamplerDescriptor desc = utils::GetDefaultSamplerDescriptor();
|
||||||
desc.magFilter = nxt::FilterMode::Nearest;
|
|
||||||
desc.minFilter = nxt::FilterMode::Nearest;
|
|
||||||
desc.mipmapFilter = nxt::FilterMode::Nearest;
|
|
||||||
// TODO: wrap modes
|
// TODO: wrap modes
|
||||||
desc.addressModeU = nxt::AddressMode::Repeat;
|
|
||||||
desc.addressModeV = nxt::AddressMode::Repeat;
|
|
||||||
desc.addressModeW = nxt::AddressMode::Repeat;
|
|
||||||
|
|
||||||
switch (iSampler.magFilter) {
|
switch (iSampler.magFilter) {
|
||||||
case gl::Nearest:
|
case gl::Nearest:
|
||||||
|
|
|
@ -137,4 +137,17 @@ namespace utils {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nxt::SamplerDescriptor GetDefaultSamplerDescriptor() {
|
||||||
|
nxt::SamplerDescriptor desc;
|
||||||
|
|
||||||
|
desc.minFilter = nxt::FilterMode::Linear;
|
||||||
|
desc.magFilter = nxt::FilterMode::Linear;
|
||||||
|
desc.mipmapFilter = nxt::FilterMode::Linear;
|
||||||
|
desc.addressModeU = nxt::AddressMode::Repeat;
|
||||||
|
desc.addressModeV = nxt::AddressMode::Repeat;
|
||||||
|
desc.addressModeW = nxt::AddressMode::Repeat;
|
||||||
|
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
|
|
|
@ -48,4 +48,6 @@ namespace utils {
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height);
|
uint32_t height);
|
||||||
|
|
||||||
|
nxt::SamplerDescriptor GetDefaultSamplerDescriptor();
|
||||||
|
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
|
|
Loading…
Reference in New Issue