mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 21:53:41 +00:00
wg_engine: fix radial fill anti-aliased drawing
Use anisotropy filter for gradient fills https://github.com/thorvg/thorvg/issues/2931
This commit is contained in:
parent
4b6f2172be
commit
0d5c3914e3
2 changed files with 6 additions and 6 deletions
|
@ -43,9 +43,9 @@ void WgContext::initialize(WGPUInstance instance, WGPUDevice device)
|
||||||
// create shared webgpu assets
|
// create shared webgpu assets
|
||||||
allocateBufferIndexFan(32768);
|
allocateBufferIndexFan(32768);
|
||||||
samplerNearestRepeat = createSampler(WGPUFilterMode_Nearest, WGPUMipmapFilterMode_Nearest, WGPUAddressMode_Repeat);
|
samplerNearestRepeat = createSampler(WGPUFilterMode_Nearest, WGPUMipmapFilterMode_Nearest, WGPUAddressMode_Repeat);
|
||||||
samplerLinearRepeat = createSampler(WGPUFilterMode_Linear, WGPUMipmapFilterMode_Linear, WGPUAddressMode_Repeat);
|
samplerLinearRepeat = createSampler(WGPUFilterMode_Linear, WGPUMipmapFilterMode_Linear, WGPUAddressMode_Repeat, 4);
|
||||||
samplerLinearMirror = createSampler(WGPUFilterMode_Linear, WGPUMipmapFilterMode_Linear, WGPUAddressMode_MirrorRepeat);
|
samplerLinearMirror = createSampler(WGPUFilterMode_Linear, WGPUMipmapFilterMode_Linear, WGPUAddressMode_MirrorRepeat, 4);
|
||||||
samplerLinearClamp = createSampler(WGPUFilterMode_Linear, WGPUMipmapFilterMode_Linear, WGPUAddressMode_ClampToEdge);
|
samplerLinearClamp = createSampler(WGPUFilterMode_Linear, WGPUMipmapFilterMode_Linear, WGPUAddressMode_ClampToEdge, 4);
|
||||||
assert(samplerNearestRepeat);
|
assert(samplerNearestRepeat);
|
||||||
assert(samplerLinearRepeat);
|
assert(samplerLinearRepeat);
|
||||||
assert(samplerLinearMirror);
|
assert(samplerLinearMirror);
|
||||||
|
@ -64,12 +64,12 @@ void WgContext::release()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WGPUSampler WgContext::createSampler(WGPUFilterMode filter, WGPUMipmapFilterMode mipmapFilter, WGPUAddressMode addrMode)
|
WGPUSampler WgContext::createSampler(WGPUFilterMode filter, WGPUMipmapFilterMode mipmapFilter, WGPUAddressMode addrMode, uint16_t anisotropy)
|
||||||
{
|
{
|
||||||
const WGPUSamplerDescriptor samplerDesc {
|
const WGPUSamplerDescriptor samplerDesc {
|
||||||
.addressModeU = addrMode, .addressModeV = addrMode, .addressModeW = addrMode,
|
.addressModeU = addrMode, .addressModeV = addrMode, .addressModeW = addrMode,
|
||||||
.magFilter = filter, .minFilter = filter, .mipmapFilter = mipmapFilter,
|
.magFilter = filter, .minFilter = filter, .mipmapFilter = mipmapFilter,
|
||||||
.lodMinClamp = 0.0f, .lodMaxClamp = 32.0f, .maxAnisotropy = 1
|
.lodMinClamp = 0.0f, .lodMaxClamp = 32.0f, .maxAnisotropy = anisotropy
|
||||||
};
|
};
|
||||||
return wgpuDeviceCreateSampler(device, &samplerDesc);
|
return wgpuDeviceCreateSampler(device, &samplerDesc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ struct WgContext {
|
||||||
void release();
|
void release();
|
||||||
|
|
||||||
// create common objects
|
// create common objects
|
||||||
WGPUSampler createSampler(WGPUFilterMode filter, WGPUMipmapFilterMode mipmapFilter, WGPUAddressMode addrMode);
|
WGPUSampler createSampler(WGPUFilterMode filter, WGPUMipmapFilterMode mipmapFilter, WGPUAddressMode addrMode, uint16_t anisotropy = 1);
|
||||||
WGPUTexture createTexture(uint32_t width, uint32_t height, WGPUTextureFormat format);
|
WGPUTexture createTexture(uint32_t width, uint32_t height, WGPUTextureFormat format);
|
||||||
WGPUTexture createTexStorage(uint32_t width, uint32_t height, WGPUTextureFormat format);
|
WGPUTexture createTexStorage(uint32_t width, uint32_t height, WGPUTextureFormat format);
|
||||||
WGPUTexture createTexAttachement(uint32_t width, uint32_t height, WGPUTextureFormat format, uint32_t sc);
|
WGPUTexture createTexAttachement(uint32_t width, uint32_t height, WGPUTextureFormat format, uint32_t sc);
|
||||||
|
|
Loading…
Add table
Reference in a new issue