Dawn: fixes for skipped call to bindTextures(), instance attributes.
If a layout has no texture bindings, don't create a texture bind group layout, and don't try to bind to them. Fix numbering of instance attributes. Bug: skia:10358 Change-Id: I9c7b12ffa72e6364b8b52d5299ba2efcf089fd88 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298120 Commit-Queue: Stephen White <senorblanco@chromium.org> Commit-Queue: Stephen White <senorblanco@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
65888b81cf
commit
768e91f7e3
@ -160,7 +160,9 @@ bool GrDawnOpsRenderPass::onBindTextures(const GrPrimitiveProcessor& primProc,
|
||||
const GrSurfaceProxy* const primProcTextures[],
|
||||
const GrPipeline& pipeline) {
|
||||
auto bindGroup = fCurrentProgram->setTextures(fGpu, primProc, pipeline, primProcTextures);
|
||||
fPassEncoder.SetBindGroup(1, bindGroup, 0, nullptr);
|
||||
if (bindGroup) {
|
||||
fPassEncoder.SetBindGroup(1, bindGroup, 0, nullptr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -325,29 +325,32 @@ sk_sp<GrDawnProgram> GrDawnProgramBuilder::Build(GrDawnGpu* gpu,
|
||||
if (0 != uniformBufferSize) {
|
||||
uniformLayoutEntries.push_back({ GrSPIRVUniformHandler::kUniformBinding,
|
||||
wgpu::ShaderStage::Vertex | wgpu::ShaderStage::Fragment,
|
||||
wgpu::BindingType::UniformBuffer});
|
||||
wgpu::BindingType::UniformBuffer });
|
||||
}
|
||||
wgpu::BindGroupLayoutDescriptor uniformBindGroupLayoutDesc;
|
||||
uniformBindGroupLayoutDesc.entryCount = uniformLayoutEntries.size();
|
||||
uniformBindGroupLayoutDesc.entries = uniformLayoutEntries.data();
|
||||
result->fBindGroupLayouts[0] =
|
||||
gpu->device().CreateBindGroupLayout(&uniformBindGroupLayoutDesc);
|
||||
result->fBindGroupLayouts.push_back(
|
||||
gpu->device().CreateBindGroupLayout(&uniformBindGroupLayoutDesc));
|
||||
uint32_t binding = 0;
|
||||
std::vector<wgpu::BindGroupLayoutEntry> textureLayoutEntries;
|
||||
for (int i = 0; i < builder.fUniformHandler.fSamplers.count(); ++i) {
|
||||
textureLayoutEntries.push_back({ binding++, wgpu::ShaderStage::Fragment,
|
||||
wgpu::BindingType::Sampler});
|
||||
textureLayoutEntries.push_back({ binding++, wgpu::ShaderStage::Fragment,
|
||||
wgpu::BindingType::SampledTexture});
|
||||
int textureCount = builder.fUniformHandler.fSamplers.count();
|
||||
if (textureCount > 0) {
|
||||
for (int i = 0; i < textureCount; ++i) {
|
||||
textureLayoutEntries.push_back({ binding++, wgpu::ShaderStage::Fragment,
|
||||
wgpu::BindingType::Sampler });
|
||||
textureLayoutEntries.push_back({ binding++, wgpu::ShaderStage::Fragment,
|
||||
wgpu::BindingType::SampledTexture });
|
||||
}
|
||||
wgpu::BindGroupLayoutDescriptor textureBindGroupLayoutDesc;
|
||||
textureBindGroupLayoutDesc.entryCount = textureLayoutEntries.size();
|
||||
textureBindGroupLayoutDesc.entries = textureLayoutEntries.data();
|
||||
result->fBindGroupLayouts.push_back(
|
||||
gpu->device().CreateBindGroupLayout(&textureBindGroupLayoutDesc));
|
||||
}
|
||||
wgpu::BindGroupLayoutDescriptor textureBindGroupLayoutDesc;
|
||||
textureBindGroupLayoutDesc.entryCount = textureLayoutEntries.size();
|
||||
textureBindGroupLayoutDesc.entries = textureLayoutEntries.data();
|
||||
result->fBindGroupLayouts[1] =
|
||||
gpu->device().CreateBindGroupLayout(&textureBindGroupLayoutDesc);
|
||||
wgpu::PipelineLayoutDescriptor pipelineLayoutDesc;
|
||||
pipelineLayoutDesc.bindGroupLayoutCount = 2;
|
||||
pipelineLayoutDesc.bindGroupLayouts = &result->fBindGroupLayouts[0];
|
||||
pipelineLayoutDesc.bindGroupLayoutCount = result->fBindGroupLayouts.size();
|
||||
pipelineLayoutDesc.bindGroupLayouts = result->fBindGroupLayouts.data();
|
||||
auto pipelineLayout = gpu->device().CreatePipelineLayout(&pipelineLayoutDesc);
|
||||
result->fBuiltinUniformHandles = builder.fUniformHandles;
|
||||
const GrPipeline& pipeline = programInfo.pipeline();
|
||||
@ -365,9 +368,9 @@ sk_sp<GrDawnProgram> GrDawnProgramBuilder::Build(GrDawnGpu* gpu,
|
||||
|
||||
std::vector<wgpu::VertexAttributeDescriptor> vertexAttributes;
|
||||
const GrPrimitiveProcessor& primProc = programInfo.primProc();
|
||||
int i = 0;
|
||||
if (primProc.numVertexAttributes() > 0) {
|
||||
size_t offset = 0;
|
||||
int i = 0;
|
||||
for (const auto& attrib : primProc.vertexAttributes()) {
|
||||
wgpu::VertexAttributeDescriptor attribute;
|
||||
attribute.shaderLocation = i;
|
||||
@ -387,7 +390,6 @@ sk_sp<GrDawnProgram> GrDawnProgramBuilder::Build(GrDawnGpu* gpu,
|
||||
std::vector<wgpu::VertexAttributeDescriptor> instanceAttributes;
|
||||
if (primProc.numInstanceAttributes() > 0) {
|
||||
size_t offset = 0;
|
||||
int i = 0;
|
||||
for (const auto& attrib : primProc.instanceAttributes()) {
|
||||
wgpu::VertexAttributeDescriptor attribute;
|
||||
attribute.shaderLocation = i;
|
||||
@ -543,6 +545,9 @@ wgpu::BindGroup GrDawnProgram::setTextures(GrDawnGpu* gpu,
|
||||
const GrPrimitiveProcessor& primProc,
|
||||
const GrPipeline& pipeline,
|
||||
const GrSurfaceProxy* const primProcTextures[]) {
|
||||
if (fBindGroupLayouts.size() < 2) {
|
||||
return nullptr;
|
||||
}
|
||||
std::vector<wgpu::BindGroupEntry> bindings;
|
||||
int binding = 0;
|
||||
if (primProcTextures) {
|
||||
|
@ -57,7 +57,7 @@ struct GrDawnProgram : public SkRefCnt {
|
||||
std::unique_ptr<GrGLSLXferProcessor> fXferProcessor;
|
||||
std::unique_ptr<std::unique_ptr<GrGLSLFragmentProcessor>[]> fFragmentProcessors;
|
||||
int fFragmentProcessorCnt;
|
||||
wgpu::BindGroupLayout fBindGroupLayouts[2];
|
||||
std::vector<wgpu::BindGroupLayout> fBindGroupLayouts;
|
||||
wgpu::RenderPipeline fRenderPipeline;
|
||||
GrDawnProgramDataManager fDataManager;
|
||||
RenderTargetState fRenderTargetState;
|
||||
|
Loading…
Reference in New Issue
Block a user