Commit e5859695 authored by Laszlo Agocs's avatar Laszlo Agocs

mtl: float tex.upload

parent d03b322b
......@@ -1261,6 +1261,35 @@ void QRhiMetal::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdate
options: MTLBlitOptionNone];
curOfs += aligned(fullImageSizeBytes, texbufAlign);
} else if (!rawData.isEmpty() && isFloatFormat(utexD->m_format)) {
const QSize subresSize = q->sizeForMipLevel(level, utexD->m_pixelSize);
const int subresw = subresSize.width();
const int subresh = subresSize.height();
int w, h;
if (mipDesc.sourceSize().isEmpty()) {
w = subresw;
h = subresh;
} else {
w = mipDesc.sourceSize().width();
h = mipDesc.sourceSize().height();
}
quint32 bpl = 0;
textureFormatInfo(utexD->m_format, QSize(w, h), &bpl, nullptr);
memcpy(reinterpret_cast<char *>(mp) + curOfs, rawData.constData(), rawData.size());
[blitEnc copyFromBuffer: utexD->d->stagingBuf[currentFrameSlot]
sourceOffset: curOfs
sourceBytesPerRow: bpl
sourceBytesPerImage: 0
sourceSize: MTLSizeMake(w, h, 1)
toTexture: utexD->d->tex
destinationSlice: layer
destinationLevel: level
destinationOrigin: MTLOriginMake(dp.x(), dp.y(), 0)
options: MTLBlitOptionNone];
curOfs += aligned(rawData.size(), texbufAlign);
} else if (!rawData.isEmpty() && isCompressedFormat(utexD->m_format)) {
const QSize subresSize = q->sizeForMipLevel(level, utexD->m_pixelSize);
const int subresw = subresSize.width();
......@@ -1299,6 +1328,8 @@ void QRhiMetal::enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdate
options: MTLBlitOptionNone];
curOfs += aligned(rawData.size(), texbufAlign);
} else {
qWarning("Invalid texture upload for %p layer=%d mip=%d", utexD, layer, level);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment