Change Sampler creation to use a descriptor instead of a builder
This commit is contained in:
parent
a6416543a4
commit
1ae19e8276
|
@ -56,9 +56,16 @@ void initTextures() {
|
||||||
.SetAllowedUsage(nxt::TextureUsageBit::TransferDst | nxt::TextureUsageBit::Sampled)
|
.SetAllowedUsage(nxt::TextureUsageBit::TransferDst | nxt::TextureUsageBit::Sampled)
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
sampler = device.CreateSamplerBuilder()
|
{
|
||||||
.SetFilterMode(nxt::FilterMode::Linear, nxt::FilterMode::Linear, nxt::FilterMode::Linear)
|
nxt::SamplerDescriptor desc;
|
||||||
.GetResult();
|
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,9 +64,16 @@ void initTextures() {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
renderTargetView = renderTarget.CreateTextureViewBuilder().GetResult();
|
renderTargetView = renderTarget.CreateTextureViewBuilder().GetResult();
|
||||||
|
|
||||||
samplerPost = device.CreateSamplerBuilder()
|
{
|
||||||
.SetFilterMode(nxt::FilterMode::Linear, nxt::FilterMode::Linear, nxt::FilterMode::Linear)
|
nxt::SamplerDescriptor desc;
|
||||||
.GetResult();
|
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,15 +336,21 @@ namespace {
|
||||||
const auto& iSamplerID = s.first;
|
const auto& iSamplerID = s.first;
|
||||||
const auto& iSampler = s.second;
|
const auto& iSampler = s.second;
|
||||||
|
|
||||||
auto magFilter = nxt::FilterMode::Nearest;
|
nxt::SamplerDescriptor desc;
|
||||||
auto minFilter = nxt::FilterMode::Nearest;
|
desc.magFilter = nxt::FilterMode::Nearest;
|
||||||
auto mipmapFilter = nxt::FilterMode::Nearest;
|
desc.minFilter = nxt::FilterMode::Nearest;
|
||||||
|
desc.mipmapFilter = nxt::FilterMode::Nearest;
|
||||||
|
// 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:
|
||||||
magFilter = nxt::FilterMode::Nearest;
|
desc.magFilter = nxt::FilterMode::Nearest;
|
||||||
break;
|
break;
|
||||||
case gl::Linear:
|
case gl::Linear:
|
||||||
magFilter = nxt::FilterMode::Linear;
|
desc.magFilter = nxt::FilterMode::Linear;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "unsupported magFilter %d\n", iSampler.magFilter);
|
fprintf(stderr, "unsupported magFilter %d\n", iSampler.magFilter);
|
||||||
|
@ -354,12 +360,12 @@ namespace {
|
||||||
case gl::Nearest:
|
case gl::Nearest:
|
||||||
case gl::NearestMipmapNearest:
|
case gl::NearestMipmapNearest:
|
||||||
case gl::NearestMipmapLinear:
|
case gl::NearestMipmapLinear:
|
||||||
minFilter = nxt::FilterMode::Nearest;
|
desc.minFilter = nxt::FilterMode::Nearest;
|
||||||
break;
|
break;
|
||||||
case gl::Linear:
|
case gl::Linear:
|
||||||
case gl::LinearMipmapNearest:
|
case gl::LinearMipmapNearest:
|
||||||
case gl::LinearMipmapLinear:
|
case gl::LinearMipmapLinear:
|
||||||
minFilter = nxt::FilterMode::Linear;
|
desc.minFilter = nxt::FilterMode::Linear;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "unsupported minFilter %d\n", iSampler.magFilter);
|
fprintf(stderr, "unsupported minFilter %d\n", iSampler.magFilter);
|
||||||
|
@ -368,20 +374,15 @@ namespace {
|
||||||
switch (iSampler.minFilter) {
|
switch (iSampler.minFilter) {
|
||||||
case gl::NearestMipmapNearest:
|
case gl::NearestMipmapNearest:
|
||||||
case gl::LinearMipmapNearest:
|
case gl::LinearMipmapNearest:
|
||||||
mipmapFilter = nxt::FilterMode::Nearest;
|
desc.mipmapFilter = nxt::FilterMode::Nearest;
|
||||||
break;
|
break;
|
||||||
case gl::NearestMipmapLinear:
|
case gl::NearestMipmapLinear:
|
||||||
case gl::LinearMipmapLinear:
|
case gl::LinearMipmapLinear:
|
||||||
mipmapFilter = nxt::FilterMode::Linear;
|
desc.mipmapFilter = nxt::FilterMode::Linear;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto oSampler = device.CreateSamplerBuilder()
|
samplers[iSamplerID] = device.CreateSampler(&desc);
|
||||||
.SetFilterMode(magFilter, minFilter, mipmapFilter)
|
|
||||||
// TODO: wrap modes
|
|
||||||
.GetResult();
|
|
||||||
|
|
||||||
samplers[iSamplerID] = std::move(oSampler);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
30
next.json
30
next.json
|
@ -616,8 +616,11 @@
|
||||||
"returns": "queue builder"
|
"returns": "queue builder"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "create sampler builder",
|
"name": "create sampler",
|
||||||
"returns": "sampler builder"
|
"returns": "sampler",
|
||||||
|
"args": [
|
||||||
|
{"name": "descriptor", "type": "sampler descriptor", "annotation": "const*"}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "create shader module builder",
|
"name": "create shader module builder",
|
||||||
|
@ -936,30 +939,17 @@
|
||||||
"sampler": {
|
"sampler": {
|
||||||
"category": "object"
|
"category": "object"
|
||||||
},
|
},
|
||||||
"sampler builder": {
|
"sampler descriptor": {
|
||||||
"category": "object",
|
"category": "structure",
|
||||||
"methods": [
|
"extensible": true,
|
||||||
{
|
"members": [
|
||||||
"name": "get result",
|
|
||||||
"returns": "sampler"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "set filter mode",
|
|
||||||
"args": [
|
|
||||||
{"name": "mag filter", "type": "filter mode"},
|
{"name": "mag filter", "type": "filter mode"},
|
||||||
{"name": "min filter", "type": "filter mode"},
|
{"name": "min filter", "type": "filter mode"},
|
||||||
{"name": "mipmap filter", "type": "filter mode"}
|
{"name": "mipmap filter", "type": "filter mode"},
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "set address mode",
|
|
||||||
"args": [
|
|
||||||
{"name": "address mode u", "type": "address mode"},
|
{"name": "address mode u", "type": "address mode"},
|
||||||
{"name": "address mode v", "type": "address mode"},
|
{"name": "address mode v", "type": "address mode"},
|
||||||
{"name": "address mode w", "type": "address mode"}
|
{"name": "address mode w", "type": "address mode"}
|
||||||
]
|
]
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"shader module": {
|
"shader module": {
|
||||||
"category": "object"
|
"category": "object"
|
||||||
|
|
|
@ -130,8 +130,11 @@ namespace backend {
|
||||||
RenderPipelineBuilder* DeviceBase::CreateRenderPipelineBuilder() {
|
RenderPipelineBuilder* DeviceBase::CreateRenderPipelineBuilder() {
|
||||||
return new RenderPipelineBuilder(this);
|
return new RenderPipelineBuilder(this);
|
||||||
}
|
}
|
||||||
SamplerBuilder* DeviceBase::CreateSamplerBuilder() {
|
SamplerBase* DeviceBase::CreateSampler(const nxt::SamplerDescriptor* descriptor) {
|
||||||
return new SamplerBuilder(this);
|
if (!ValidateSamplerDescriptor(this, descriptor)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return CreateSamplerImpl(descriptor);
|
||||||
}
|
}
|
||||||
ShaderModuleBuilder* DeviceBase::CreateShaderModuleBuilder() {
|
ShaderModuleBuilder* DeviceBase::CreateShaderModuleBuilder() {
|
||||||
return new ShaderModuleBuilder(this);
|
return new ShaderModuleBuilder(this);
|
||||||
|
|
|
@ -49,7 +49,6 @@ namespace backend {
|
||||||
virtual RenderPassDescriptorBase* CreateRenderPassDescriptor(
|
virtual RenderPassDescriptorBase* CreateRenderPassDescriptor(
|
||||||
RenderPassDescriptorBuilder* builder) = 0;
|
RenderPassDescriptorBuilder* builder) = 0;
|
||||||
virtual RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) = 0;
|
virtual RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) = 0;
|
||||||
virtual SamplerBase* CreateSampler(SamplerBuilder* builder) = 0;
|
|
||||||
virtual ShaderModuleBase* CreateShaderModule(ShaderModuleBuilder* builder) = 0;
|
virtual ShaderModuleBase* CreateShaderModule(ShaderModuleBuilder* builder) = 0;
|
||||||
virtual SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) = 0;
|
virtual SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) = 0;
|
||||||
virtual TextureBase* CreateTexture(TextureBuilder* builder) = 0;
|
virtual TextureBase* CreateTexture(TextureBuilder* builder) = 0;
|
||||||
|
@ -88,7 +87,7 @@ namespace backend {
|
||||||
QueueBuilder* CreateQueueBuilder();
|
QueueBuilder* CreateQueueBuilder();
|
||||||
RenderPassDescriptorBuilder* CreateRenderPassDescriptorBuilder();
|
RenderPassDescriptorBuilder* CreateRenderPassDescriptorBuilder();
|
||||||
RenderPipelineBuilder* CreateRenderPipelineBuilder();
|
RenderPipelineBuilder* CreateRenderPipelineBuilder();
|
||||||
SamplerBuilder* CreateSamplerBuilder();
|
SamplerBase* CreateSampler(const nxt::SamplerDescriptor* descriptor);
|
||||||
ShaderModuleBuilder* CreateShaderModuleBuilder();
|
ShaderModuleBuilder* CreateShaderModuleBuilder();
|
||||||
SwapChainBuilder* CreateSwapChainBuilder();
|
SwapChainBuilder* CreateSwapChainBuilder();
|
||||||
TextureBuilder* CreateTextureBuilder();
|
TextureBuilder* CreateTextureBuilder();
|
||||||
|
@ -99,6 +98,8 @@ namespace backend {
|
||||||
void Release();
|
void Release();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
virtual SamplerBase* CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) = 0;
|
||||||
|
|
||||||
// The object caches aren't exposed in the header as they would require a lot of
|
// The object caches aren't exposed in the header as they would require a lot of
|
||||||
// additional includes.
|
// additional includes.
|
||||||
struct Caches;
|
struct Caches;
|
||||||
|
|
|
@ -46,7 +46,6 @@ namespace backend {
|
||||||
class RenderPipelineBase;
|
class RenderPipelineBase;
|
||||||
class RenderPipelineBuilder;
|
class RenderPipelineBuilder;
|
||||||
class SamplerBase;
|
class SamplerBase;
|
||||||
class SamplerBuilder;
|
|
||||||
class ShaderModuleBase;
|
class ShaderModuleBase;
|
||||||
class ShaderModuleBuilder;
|
class ShaderModuleBuilder;
|
||||||
class SwapChainBase;
|
class SwapChainBase;
|
||||||
|
|
|
@ -15,77 +15,22 @@
|
||||||
#include "backend/Sampler.h"
|
#include "backend/Sampler.h"
|
||||||
|
|
||||||
#include "backend/Device.h"
|
#include "backend/Device.h"
|
||||||
|
#include "backend/ValidationUtils_autogen.h"
|
||||||
|
|
||||||
namespace backend {
|
namespace backend {
|
||||||
|
|
||||||
|
bool ValidateSamplerDescriptor(DeviceBase*, const nxt::SamplerDescriptor* descriptor) {
|
||||||
|
return descriptor->nextInChain == nullptr && IsValidFilterMode(descriptor->magFilter) &&
|
||||||
|
IsValidFilterMode(descriptor->minFilter) &&
|
||||||
|
IsValidFilterMode(descriptor->mipmapFilter) &&
|
||||||
|
IsValidAddressMode(descriptor->addressModeU) &&
|
||||||
|
IsValidAddressMode(descriptor->addressModeV) &&
|
||||||
|
IsValidAddressMode(descriptor->addressModeW);
|
||||||
|
}
|
||||||
|
|
||||||
// SamplerBase
|
// SamplerBase
|
||||||
|
|
||||||
SamplerBase::SamplerBase(SamplerBuilder*) {
|
SamplerBase::SamplerBase(DeviceBase*, const nxt::SamplerDescriptor*) {
|
||||||
}
|
|
||||||
|
|
||||||
// SamplerBuilder
|
|
||||||
|
|
||||||
enum SamplerSetProperties {
|
|
||||||
SAMPLER_PROPERTY_FILTER = 0x1,
|
|
||||||
SAMPLER_PROPERTY_ADDRESS = 0x2,
|
|
||||||
};
|
|
||||||
SamplerBuilder::SamplerBuilder(DeviceBase* device) : Builder(device) {
|
|
||||||
}
|
|
||||||
|
|
||||||
nxt::FilterMode SamplerBuilder::GetMagFilter() const {
|
|
||||||
return mMagFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
nxt::FilterMode SamplerBuilder::GetMinFilter() const {
|
|
||||||
return mMinFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
nxt::FilterMode SamplerBuilder::GetMipMapFilter() const {
|
|
||||||
return mMipMapFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
nxt::AddressMode SamplerBuilder::GetAddressModeU() const {
|
|
||||||
return mAddressModeU;
|
|
||||||
}
|
|
||||||
|
|
||||||
nxt::AddressMode SamplerBuilder::GetAddressModeV() const {
|
|
||||||
return mAddressModeV;
|
|
||||||
}
|
|
||||||
|
|
||||||
nxt::AddressMode SamplerBuilder::GetAddressModeW() const {
|
|
||||||
return mAddressModeW;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SamplerBuilder::SetFilterMode(nxt::FilterMode magFilter,
|
|
||||||
nxt::FilterMode minFilter,
|
|
||||||
nxt::FilterMode mipMapFilter) {
|
|
||||||
if ((mPropertiesSet & SAMPLER_PROPERTY_FILTER) != 0) {
|
|
||||||
HandleError("Sampler filter property set multiple times");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mMagFilter = magFilter;
|
|
||||||
mMinFilter = minFilter;
|
|
||||||
mMipMapFilter = mipMapFilter;
|
|
||||||
mPropertiesSet |= SAMPLER_PROPERTY_FILTER;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SamplerBuilder::SetAddressMode(nxt::AddressMode addressModeU,
|
|
||||||
nxt::AddressMode addressModeV,
|
|
||||||
nxt::AddressMode addressModeW) {
|
|
||||||
if ((mPropertiesSet & SAMPLER_PROPERTY_ADDRESS) != 0) {
|
|
||||||
HandleError("Sampler address property set multiple times");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mAddressModeU = addressModeU;
|
|
||||||
mAddressModeV = addressModeV;
|
|
||||||
mAddressModeW = addressModeW;
|
|
||||||
mPropertiesSet |= SAMPLER_PROPERTY_ADDRESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
SamplerBase* SamplerBuilder::GetResultImpl() {
|
|
||||||
return mDevice->CreateSampler(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace backend
|
} // namespace backend
|
||||||
|
|
|
@ -15,54 +15,19 @@
|
||||||
#ifndef BACKEND_SAMPLER_H_
|
#ifndef BACKEND_SAMPLER_H_
|
||||||
#define BACKEND_SAMPLER_H_
|
#define BACKEND_SAMPLER_H_
|
||||||
|
|
||||||
#include "backend/Buffer.h"
|
|
||||||
#include "backend/Forward.h"
|
|
||||||
#include "backend/RefCounted.h"
|
#include "backend/RefCounted.h"
|
||||||
|
|
||||||
#include "nxt/nxtcpp.h"
|
#include "nxt/nxtcpp.h"
|
||||||
|
|
||||||
namespace backend {
|
namespace backend {
|
||||||
|
|
||||||
|
class DeviceBase;
|
||||||
|
|
||||||
|
bool ValidateSamplerDescriptor(DeviceBase* device, const nxt::SamplerDescriptor* descriptor);
|
||||||
|
|
||||||
class SamplerBase : public RefCounted {
|
class SamplerBase : public RefCounted {
|
||||||
public:
|
public:
|
||||||
SamplerBase(SamplerBuilder* builder);
|
SamplerBase(DeviceBase* device, const nxt::SamplerDescriptor* descriptor);
|
||||||
};
|
|
||||||
|
|
||||||
class SamplerBuilder : public Builder<SamplerBase> {
|
|
||||||
public:
|
|
||||||
SamplerBuilder(DeviceBase* device);
|
|
||||||
|
|
||||||
nxt::FilterMode GetMagFilter() const;
|
|
||||||
nxt::FilterMode GetMinFilter() const;
|
|
||||||
nxt::FilterMode GetMipMapFilter() const;
|
|
||||||
|
|
||||||
nxt::AddressMode GetAddressModeU() const;
|
|
||||||
nxt::AddressMode GetAddressModeV() const;
|
|
||||||
nxt::AddressMode GetAddressModeW() const;
|
|
||||||
|
|
||||||
// NXT API
|
|
||||||
void SetFilterMode(nxt::FilterMode magFilter,
|
|
||||||
nxt::FilterMode minFilter,
|
|
||||||
nxt::FilterMode mipMapFilter);
|
|
||||||
|
|
||||||
void SetAddressMode(nxt::AddressMode addressModeU,
|
|
||||||
nxt::AddressMode addressModeV,
|
|
||||||
nxt::AddressMode addressModeW);
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class SamplerBase;
|
|
||||||
|
|
||||||
SamplerBase* GetResultImpl() override;
|
|
||||||
|
|
||||||
int mPropertiesSet = 0;
|
|
||||||
|
|
||||||
nxt::FilterMode mMagFilter = nxt::FilterMode::Nearest;
|
|
||||||
nxt::FilterMode mMinFilter = nxt::FilterMode::Nearest;
|
|
||||||
nxt::FilterMode mMipMapFilter = nxt::FilterMode::Nearest;
|
|
||||||
|
|
||||||
nxt::AddressMode mAddressModeU = nxt::AddressMode::ClampToEdge;
|
|
||||||
nxt::AddressMode mAddressModeV = nxt::AddressMode::ClampToEdge;
|
|
||||||
nxt::AddressMode mAddressModeW = nxt::AddressMode::ClampToEdge;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace backend
|
} // namespace backend
|
||||||
|
|
|
@ -298,8 +298,8 @@ namespace backend { namespace d3d12 {
|
||||||
RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
|
RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
|
||||||
return new RenderPipeline(builder);
|
return new RenderPipeline(builder);
|
||||||
}
|
}
|
||||||
SamplerBase* Device::CreateSampler(SamplerBuilder* builder) {
|
SamplerBase* Device::CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) {
|
||||||
return new Sampler(builder);
|
return new Sampler(this, descriptor);
|
||||||
}
|
}
|
||||||
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {
|
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {
|
||||||
return new ShaderModule(this, builder);
|
return new ShaderModule(this, builder);
|
||||||
|
|
|
@ -100,7 +100,6 @@ namespace backend { namespace d3d12 {
|
||||||
RenderPassDescriptorBase* CreateRenderPassDescriptor(
|
RenderPassDescriptorBase* CreateRenderPassDescriptor(
|
||||||
RenderPassDescriptorBuilder* builder) override;
|
RenderPassDescriptorBuilder* builder) override;
|
||||||
RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
|
RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
|
||||||
SamplerBase* CreateSampler(SamplerBuilder* builder) override;
|
|
||||||
ShaderModuleBase* CreateShaderModule(ShaderModuleBuilder* builder) override;
|
ShaderModuleBase* CreateShaderModule(ShaderModuleBuilder* builder) override;
|
||||||
SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
|
SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
|
||||||
TextureBase* CreateTexture(TextureBuilder* builder) override;
|
TextureBase* CreateTexture(TextureBuilder* builder) override;
|
||||||
|
@ -129,6 +128,8 @@ namespace backend { namespace d3d12 {
|
||||||
void ExecuteCommandLists(std::initializer_list<ID3D12CommandList*> commandLists);
|
void ExecuteCommandLists(std::initializer_list<ID3D12CommandList*> commandLists);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
SamplerBase* CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) override;
|
||||||
|
|
||||||
uint64_t mSerial = 0;
|
uint64_t mSerial = 0;
|
||||||
ComPtr<ID3D12Fence> mFence;
|
ComPtr<ID3D12Fence> mFence;
|
||||||
HANDLE mFenceEvent;
|
HANDLE mFenceEvent;
|
||||||
|
|
|
@ -57,7 +57,7 @@ namespace backend { namespace d3d12 {
|
||||||
RenderPassDescriptor::GetSubpassOMSetRenderTargetArgs() {
|
RenderPassDescriptor::GetSubpassOMSetRenderTargetArgs() {
|
||||||
OMSetRenderTargetArgs args = {};
|
OMSetRenderTargetArgs args = {};
|
||||||
|
|
||||||
size_t rtvIndex = 0;
|
unsigned int rtvIndex = 0;
|
||||||
for (uint32_t i : IterateBitSet(GetColorAttachmentMask())) {
|
for (uint32_t i : IterateBitSet(GetColorAttachmentMask())) {
|
||||||
args.RTVs[rtvIndex] = GetRTVDescriptor(i);
|
args.RTVs[rtvIndex] = GetRTVDescriptor(i);
|
||||||
rtvIndex++;
|
rtvIndex++;
|
||||||
|
|
|
@ -33,7 +33,8 @@ namespace backend { namespace d3d12 {
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Sampler::Sampler(SamplerBuilder* builder) : SamplerBase(builder) {
|
Sampler::Sampler(Device* device, const nxt::SamplerDescriptor* descriptor)
|
||||||
|
: SamplerBase(device, descriptor) {
|
||||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/dn770367(v=vs.85).aspx
|
// https://msdn.microsoft.com/en-us/library/windows/desktop/dn770367(v=vs.85).aspx
|
||||||
// hex value, decimal value, min linear, mag linear, mip linear
|
// hex value, decimal value, min linear, mag linear, mip linear
|
||||||
// D3D12_FILTER_MIN_MAG_MIP_POINT = 0 0 0 0 0
|
// D3D12_FILTER_MIN_MAG_MIP_POINT = 0 0 0 0 0
|
||||||
|
@ -51,7 +52,7 @@ namespace backend { namespace d3d12 {
|
||||||
|
|
||||||
uint8_t mode = 0;
|
uint8_t mode = 0;
|
||||||
|
|
||||||
switch (builder->GetMinFilter()) {
|
switch (descriptor->minFilter) {
|
||||||
case nxt::FilterMode::Nearest:
|
case nxt::FilterMode::Nearest:
|
||||||
break;
|
break;
|
||||||
case nxt::FilterMode::Linear:
|
case nxt::FilterMode::Linear:
|
||||||
|
@ -59,7 +60,7 @@ namespace backend { namespace d3d12 {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (builder->GetMagFilter()) {
|
switch (descriptor->magFilter) {
|
||||||
case nxt::FilterMode::Nearest:
|
case nxt::FilterMode::Nearest:
|
||||||
break;
|
break;
|
||||||
case nxt::FilterMode::Linear:
|
case nxt::FilterMode::Linear:
|
||||||
|
@ -67,7 +68,7 @@ namespace backend { namespace d3d12 {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (builder->GetMipMapFilter()) {
|
switch (descriptor->mipmapFilter) {
|
||||||
case nxt::FilterMode::Nearest:
|
case nxt::FilterMode::Nearest:
|
||||||
break;
|
break;
|
||||||
case nxt::FilterMode::Linear:
|
case nxt::FilterMode::Linear:
|
||||||
|
@ -76,9 +77,9 @@ namespace backend { namespace d3d12 {
|
||||||
}
|
}
|
||||||
|
|
||||||
mSamplerDesc.Filter = static_cast<D3D12_FILTER>(mode);
|
mSamplerDesc.Filter = static_cast<D3D12_FILTER>(mode);
|
||||||
mSamplerDesc.AddressU = AddressMode(builder->GetAddressModeU());
|
mSamplerDesc.AddressU = AddressMode(descriptor->addressModeU);
|
||||||
mSamplerDesc.AddressV = AddressMode(builder->GetAddressModeV());
|
mSamplerDesc.AddressV = AddressMode(descriptor->addressModeV);
|
||||||
mSamplerDesc.AddressW = AddressMode(builder->GetAddressModeW());
|
mSamplerDesc.AddressW = AddressMode(descriptor->addressModeW);
|
||||||
mSamplerDesc.MipLODBias = 0.f;
|
mSamplerDesc.MipLODBias = 0.f;
|
||||||
mSamplerDesc.MaxAnisotropy = 1;
|
mSamplerDesc.MaxAnisotropy = 1;
|
||||||
mSamplerDesc.ComparisonFunc = D3D12_COMPARISON_FUNC_ALWAYS;
|
mSamplerDesc.ComparisonFunc = D3D12_COMPARISON_FUNC_ALWAYS;
|
||||||
|
|
|
@ -21,9 +21,11 @@
|
||||||
|
|
||||||
namespace backend { namespace d3d12 {
|
namespace backend { namespace d3d12 {
|
||||||
|
|
||||||
|
class Device;
|
||||||
|
|
||||||
class Sampler : public SamplerBase {
|
class Sampler : public SamplerBase {
|
||||||
public:
|
public:
|
||||||
Sampler(SamplerBuilder* builder);
|
Sampler(Device* device, const nxt::SamplerDescriptor* descriptor);
|
||||||
|
|
||||||
const D3D12_SAMPLER_DESC& GetSamplerDescriptor() const;
|
const D3D12_SAMPLER_DESC& GetSamplerDescriptor() const;
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,6 @@ namespace backend { namespace metal {
|
||||||
RenderPassDescriptorBase* CreateRenderPassDescriptor(
|
RenderPassDescriptorBase* CreateRenderPassDescriptor(
|
||||||
RenderPassDescriptorBuilder* builder) override;
|
RenderPassDescriptorBuilder* builder) override;
|
||||||
RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
|
RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
|
||||||
SamplerBase* CreateSampler(SamplerBuilder* builder) override;
|
|
||||||
ShaderModuleBase* CreateShaderModule(ShaderModuleBuilder* builder) override;
|
ShaderModuleBase* CreateShaderModule(ShaderModuleBuilder* builder) override;
|
||||||
SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
|
SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
|
||||||
TextureBase* CreateTexture(TextureBuilder* builder) override;
|
TextureBase* CreateTexture(TextureBuilder* builder) override;
|
||||||
|
@ -119,6 +118,8 @@ namespace backend { namespace metal {
|
||||||
ResourceUploader* GetResourceUploader() const;
|
ResourceUploader* GetResourceUploader() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
SamplerBase* CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) override;
|
||||||
|
|
||||||
void OnCompletedHandler();
|
void OnCompletedHandler();
|
||||||
|
|
||||||
id<MTLDevice> mMtlDevice = nil;
|
id<MTLDevice> mMtlDevice = nil;
|
||||||
|
|
|
@ -117,8 +117,8 @@ namespace backend { namespace metal {
|
||||||
RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
|
RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
|
||||||
return new RenderPipeline(builder);
|
return new RenderPipeline(builder);
|
||||||
}
|
}
|
||||||
SamplerBase* Device::CreateSampler(SamplerBuilder* builder) {
|
SamplerBase* Device::CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) {
|
||||||
return new Sampler(builder);
|
return new Sampler(this, descriptor);
|
||||||
}
|
}
|
||||||
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {
|
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {
|
||||||
return new ShaderModule(builder);
|
return new ShaderModule(builder);
|
||||||
|
|
|
@ -21,9 +21,11 @@
|
||||||
|
|
||||||
namespace backend { namespace metal {
|
namespace backend { namespace metal {
|
||||||
|
|
||||||
|
class Device;
|
||||||
|
|
||||||
class Sampler : public SamplerBase {
|
class Sampler : public SamplerBase {
|
||||||
public:
|
public:
|
||||||
Sampler(SamplerBuilder* builder);
|
Sampler(Device* device, const nxt::SamplerDescriptor* descriptor);
|
||||||
~Sampler();
|
~Sampler();
|
||||||
|
|
||||||
id<MTLSamplerState> GetMTLSamplerState();
|
id<MTLSamplerState> GetMTLSamplerState();
|
||||||
|
|
|
@ -49,19 +49,19 @@ namespace backend { namespace metal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Sampler::Sampler(SamplerBuilder* builder) : SamplerBase(builder) {
|
Sampler::Sampler(Device* device, const nxt::SamplerDescriptor* descriptor)
|
||||||
auto desc = [MTLSamplerDescriptor new];
|
: SamplerBase(device, descriptor) {
|
||||||
[desc autorelease];
|
MTLSamplerDescriptor* mtlDesc = [MTLSamplerDescriptor new];
|
||||||
desc.minFilter = FilterModeToMinMagFilter(builder->GetMinFilter());
|
[mtlDesc autorelease];
|
||||||
desc.magFilter = FilterModeToMinMagFilter(builder->GetMagFilter());
|
mtlDesc.minFilter = FilterModeToMinMagFilter(descriptor->minFilter);
|
||||||
desc.mipFilter = FilterModeToMipFilter(builder->GetMipMapFilter());
|
mtlDesc.magFilter = FilterModeToMinMagFilter(descriptor->magFilter);
|
||||||
|
mtlDesc.mipFilter = FilterModeToMipFilter(descriptor->mipmapFilter);
|
||||||
|
|
||||||
desc.sAddressMode = AddressMode(builder->GetAddressModeU());
|
mtlDesc.sAddressMode = AddressMode(descriptor->addressModeU);
|
||||||
desc.tAddressMode = AddressMode(builder->GetAddressModeV());
|
mtlDesc.tAddressMode = AddressMode(descriptor->addressModeV);
|
||||||
desc.rAddressMode = AddressMode(builder->GetAddressModeW());
|
mtlDesc.rAddressMode = AddressMode(descriptor->addressModeW);
|
||||||
|
|
||||||
auto mtlDevice = ToBackend(builder->GetDevice())->GetMTLDevice();
|
mMtlSamplerState = [device->GetMTLDevice() newSamplerStateWithDescriptor:mtlDesc];
|
||||||
mMtlSamplerState = [mtlDevice newSamplerStateWithDescriptor:desc];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Sampler::~Sampler() {
|
Sampler::~Sampler() {
|
||||||
|
|
|
@ -76,8 +76,8 @@ namespace backend { namespace null {
|
||||||
RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
|
RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
|
||||||
return new RenderPipeline(builder);
|
return new RenderPipeline(builder);
|
||||||
}
|
}
|
||||||
SamplerBase* Device::CreateSampler(SamplerBuilder* builder) {
|
SamplerBase* Device::CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) {
|
||||||
return new Sampler(builder);
|
return new Sampler(this, descriptor);
|
||||||
}
|
}
|
||||||
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {
|
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {
|
||||||
auto module = new ShaderModule(builder);
|
auto module = new ShaderModule(builder);
|
||||||
|
|
|
@ -109,7 +109,6 @@ namespace backend { namespace null {
|
||||||
RenderPassDescriptorBase* CreateRenderPassDescriptor(
|
RenderPassDescriptorBase* CreateRenderPassDescriptor(
|
||||||
RenderPassDescriptorBuilder* builder) override;
|
RenderPassDescriptorBuilder* builder) override;
|
||||||
RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
|
RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
|
||||||
SamplerBase* CreateSampler(SamplerBuilder* builder) override;
|
|
||||||
ShaderModuleBase* CreateShaderModule(ShaderModuleBuilder* builder) override;
|
ShaderModuleBase* CreateShaderModule(ShaderModuleBuilder* builder) override;
|
||||||
SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
|
SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
|
||||||
TextureBase* CreateTexture(TextureBuilder* builder) override;
|
TextureBase* CreateTexture(TextureBuilder* builder) override;
|
||||||
|
@ -121,6 +120,8 @@ namespace backend { namespace null {
|
||||||
std::vector<std::unique_ptr<PendingOperation>> AcquirePendingOperations();
|
std::vector<std::unique_ptr<PendingOperation>> AcquirePendingOperations();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
SamplerBase* CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) override;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<PendingOperation>> mPendingOperations;
|
std::vector<std::unique_ptr<PendingOperation>> mPendingOperations;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -86,8 +86,8 @@ namespace backend { namespace opengl {
|
||||||
RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
|
RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
|
||||||
return new RenderPipeline(builder);
|
return new RenderPipeline(builder);
|
||||||
}
|
}
|
||||||
SamplerBase* Device::CreateSampler(SamplerBuilder* builder) {
|
SamplerBase* Device::CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) {
|
||||||
return new Sampler(builder);
|
return new Sampler(this, descriptor);
|
||||||
}
|
}
|
||||||
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {
|
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {
|
||||||
return new ShaderModule(builder);
|
return new ShaderModule(builder);
|
||||||
|
|
|
@ -97,13 +97,15 @@ namespace backend { namespace opengl {
|
||||||
RenderPassDescriptorBase* CreateRenderPassDescriptor(
|
RenderPassDescriptorBase* CreateRenderPassDescriptor(
|
||||||
RenderPassDescriptorBuilder* builder) override;
|
RenderPassDescriptorBuilder* builder) override;
|
||||||
RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
|
RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
|
||||||
SamplerBase* CreateSampler(SamplerBuilder* builder) override;
|
|
||||||
ShaderModuleBase* CreateShaderModule(ShaderModuleBuilder* builder) override;
|
ShaderModuleBase* CreateShaderModule(ShaderModuleBuilder* builder) override;
|
||||||
SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
|
SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
|
||||||
TextureBase* CreateTexture(TextureBuilder* builder) override;
|
TextureBase* CreateTexture(TextureBuilder* builder) override;
|
||||||
TextureViewBase* CreateTextureView(TextureViewBuilder* builder) override;
|
TextureViewBase* CreateTextureView(TextureViewBuilder* builder) override;
|
||||||
|
|
||||||
void TickImpl() override;
|
void TickImpl() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SamplerBase* CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BindGroup : public BindGroupBase {
|
class BindGroup : public BindGroupBase {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "backend/opengl/SamplerGL.h"
|
#include "backend/opengl/SamplerGL.h"
|
||||||
|
|
||||||
|
#include "backend/opengl/OpenGLBackend.h"
|
||||||
#include "common/Assert.h"
|
#include "common/Assert.h"
|
||||||
|
|
||||||
namespace backend { namespace opengl {
|
namespace backend { namespace opengl {
|
||||||
|
@ -70,14 +71,15 @@ namespace backend { namespace opengl {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Sampler::Sampler(SamplerBuilder* builder) : SamplerBase(builder) {
|
Sampler::Sampler(Device* device, const nxt::SamplerDescriptor* descriptor)
|
||||||
|
: SamplerBase(device, descriptor) {
|
||||||
glGenSamplers(1, &mHandle);
|
glGenSamplers(1, &mHandle);
|
||||||
glSamplerParameteri(mHandle, GL_TEXTURE_MAG_FILTER, MagFilterMode(builder->GetMagFilter()));
|
glSamplerParameteri(mHandle, GL_TEXTURE_MAG_FILTER, MagFilterMode(descriptor->magFilter));
|
||||||
glSamplerParameteri(mHandle, GL_TEXTURE_MIN_FILTER,
|
glSamplerParameteri(mHandle, GL_TEXTURE_MIN_FILTER,
|
||||||
MinFilterMode(builder->GetMinFilter(), builder->GetMipMapFilter()));
|
MinFilterMode(descriptor->minFilter, descriptor->mipmapFilter));
|
||||||
glSamplerParameteri(mHandle, GL_TEXTURE_WRAP_R, WrapMode(builder->GetAddressModeW()));
|
glSamplerParameteri(mHandle, GL_TEXTURE_WRAP_R, WrapMode(descriptor->addressModeW));
|
||||||
glSamplerParameteri(mHandle, GL_TEXTURE_WRAP_S, WrapMode(builder->GetAddressModeU()));
|
glSamplerParameteri(mHandle, GL_TEXTURE_WRAP_S, WrapMode(descriptor->addressModeU));
|
||||||
glSamplerParameteri(mHandle, GL_TEXTURE_WRAP_T, WrapMode(builder->GetAddressModeV()));
|
glSamplerParameteri(mHandle, GL_TEXTURE_WRAP_T, WrapMode(descriptor->addressModeV));
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint Sampler::GetHandle() const {
|
GLuint Sampler::GetHandle() const {
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace backend { namespace opengl {
|
||||||
|
|
||||||
class Sampler : public SamplerBase {
|
class Sampler : public SamplerBase {
|
||||||
public:
|
public:
|
||||||
Sampler(SamplerBuilder* builder);
|
Sampler(Device* device, const nxt::SamplerDescriptor* descriptor);
|
||||||
|
|
||||||
GLuint GetHandle() const;
|
GLuint GetHandle() const;
|
||||||
|
|
||||||
|
|
|
@ -56,18 +56,18 @@ namespace backend { namespace vulkan {
|
||||||
}
|
}
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
Sampler::Sampler(SamplerBuilder* builder)
|
Sampler::Sampler(Device* device, const nxt::SamplerDescriptor* descriptor)
|
||||||
: SamplerBase(builder), mDevice(ToBackend(builder->GetDevice())) {
|
: SamplerBase(device, descriptor), mDevice(device) {
|
||||||
VkSamplerCreateInfo createInfo;
|
VkSamplerCreateInfo createInfo;
|
||||||
createInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
createInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
||||||
createInfo.pNext = nullptr;
|
createInfo.pNext = nullptr;
|
||||||
createInfo.flags = 0;
|
createInfo.flags = 0;
|
||||||
createInfo.magFilter = VulkanSamplerFilter(builder->GetMagFilter());
|
createInfo.magFilter = VulkanSamplerFilter(descriptor->magFilter);
|
||||||
createInfo.minFilter = VulkanSamplerFilter(builder->GetMinFilter());
|
createInfo.minFilter = VulkanSamplerFilter(descriptor->minFilter);
|
||||||
createInfo.mipmapMode = VulkanMipMapMode(builder->GetMipMapFilter());
|
createInfo.mipmapMode = VulkanMipMapMode(descriptor->mipmapFilter);
|
||||||
createInfo.addressModeU = VulkanSamplerAddressMode(builder->GetAddressModeU());
|
createInfo.addressModeU = VulkanSamplerAddressMode(descriptor->addressModeU);
|
||||||
createInfo.addressModeV = VulkanSamplerAddressMode(builder->GetAddressModeV());
|
createInfo.addressModeV = VulkanSamplerAddressMode(descriptor->addressModeV);
|
||||||
createInfo.addressModeW = VulkanSamplerAddressMode(builder->GetAddressModeW());
|
createInfo.addressModeW = VulkanSamplerAddressMode(descriptor->addressModeW);
|
||||||
createInfo.mipLodBias = 0.0f;
|
createInfo.mipLodBias = 0.0f;
|
||||||
createInfo.anisotropyEnable = VK_FALSE;
|
createInfo.anisotropyEnable = VK_FALSE;
|
||||||
createInfo.maxAnisotropy = 1.0f;
|
createInfo.maxAnisotropy = 1.0f;
|
||||||
|
@ -78,7 +78,7 @@ namespace backend { namespace vulkan {
|
||||||
createInfo.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
|
createInfo.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
|
||||||
createInfo.unnormalizedCoordinates = VK_FALSE;
|
createInfo.unnormalizedCoordinates = VK_FALSE;
|
||||||
|
|
||||||
if (mDevice->fn.CreateSampler(mDevice->GetVkDevice(), &createInfo, nullptr, &mHandle) !=
|
if (device->fn.CreateSampler(device->GetVkDevice(), &createInfo, nullptr, &mHandle) !=
|
||||||
VK_SUCCESS) {
|
VK_SUCCESS) {
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace backend { namespace vulkan {
|
||||||
|
|
||||||
class Sampler : public SamplerBase {
|
class Sampler : public SamplerBase {
|
||||||
public:
|
public:
|
||||||
Sampler(SamplerBuilder* builder);
|
Sampler(Device* device, const nxt::SamplerDescriptor* descriptor);
|
||||||
~Sampler();
|
~Sampler();
|
||||||
|
|
||||||
VkSampler GetHandle() const;
|
VkSampler GetHandle() const;
|
||||||
|
|
|
@ -253,8 +253,8 @@ namespace backend { namespace vulkan {
|
||||||
RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
|
RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
|
||||||
return new RenderPipeline(builder);
|
return new RenderPipeline(builder);
|
||||||
}
|
}
|
||||||
SamplerBase* Device::CreateSampler(SamplerBuilder* builder) {
|
SamplerBase* Device::CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) {
|
||||||
return new Sampler(builder);
|
return new Sampler(this, descriptor);
|
||||||
}
|
}
|
||||||
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {
|
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {
|
||||||
return new ShaderModule(builder);
|
return new ShaderModule(builder);
|
||||||
|
|
|
@ -125,7 +125,6 @@ namespace backend { namespace vulkan {
|
||||||
RenderPassDescriptorBase* CreateRenderPassDescriptor(
|
RenderPassDescriptorBase* CreateRenderPassDescriptor(
|
||||||
RenderPassDescriptorBuilder* builder) override;
|
RenderPassDescriptorBuilder* builder) override;
|
||||||
RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
|
RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
|
||||||
SamplerBase* CreateSampler(SamplerBuilder* builder) override;
|
|
||||||
ShaderModuleBase* CreateShaderModule(ShaderModuleBuilder* builder) override;
|
ShaderModuleBase* CreateShaderModule(ShaderModuleBuilder* builder) override;
|
||||||
SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
|
SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
|
||||||
TextureBase* CreateTexture(TextureBuilder* builder) override;
|
TextureBase* CreateTexture(TextureBuilder* builder) override;
|
||||||
|
@ -134,6 +133,8 @@ namespace backend { namespace vulkan {
|
||||||
void TickImpl() override;
|
void TickImpl() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
SamplerBase* CreateSamplerImpl(const nxt::SamplerDescriptor* descriptor) override;
|
||||||
|
|
||||||
bool CreateInstance(VulkanGlobalKnobs* usedKnobs,
|
bool CreateInstance(VulkanGlobalKnobs* usedKnobs,
|
||||||
const std::vector<const char*>& requiredExtensions);
|
const std::vector<const char*>& requiredExtensions);
|
||||||
bool CreateDevice(VulkanDeviceKnobs* usedKnobs);
|
bool CreateDevice(VulkanDeviceKnobs* usedKnobs);
|
||||||
|
|
|
@ -110,10 +110,17 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestAddressModes(AddressModeTestCase u, AddressModeTestCase v, AddressModeTestCase w) {
|
void TestAddressModes(AddressModeTestCase u, AddressModeTestCase v, AddressModeTestCase w) {
|
||||||
|
nxt::Sampler sampler;
|
||||||
nxt::Sampler sampler = device.CreateSamplerBuilder()
|
{
|
||||||
.SetAddressMode(u.mMode, v.mMode, w.mMode)
|
nxt::SamplerDescriptor descriptor;
|
||||||
.GetResult();
|
descriptor.minFilter = nxt::FilterMode::Nearest;
|
||||||
|
descriptor.magFilter = nxt::FilterMode::Nearest;
|
||||||
|
descriptor.mipmapFilter = nxt::FilterMode::Nearest;
|
||||||
|
descriptor.addressModeU = u.mMode;
|
||||||
|
descriptor.addressModeV = v.mMode;
|
||||||
|
descriptor.addressModeW = w.mMode;
|
||||||
|
sampler = device.CreateSampler(&descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
auto bindGroup = device.CreateBindGroupBuilder()
|
auto bindGroup = device.CreateBindGroupBuilder()
|
||||||
.SetLayout(mBindGroupLayout)
|
.SetLayout(mBindGroupLayout)
|
||||||
|
|
Loading…
Reference in New Issue