dx compatiblity

This commit is contained in:
Mikulas Florek 2019-11-19 00:11:09 +01:00
parent 1cb5b18320
commit 0a6e1263fe
7 changed files with 10 additions and 13 deletions

View file

@ -846,9 +846,9 @@ struct CaptureImpostorJob : Renderer::RenderJob {
const u32 flags = u32(gpu::TextureFlags::NO_MIPS) | u32(gpu::TextureFlags::READBACK);
gpu::createTexture(staging, texture_size.x, texture_size.y, 1, gpu::TextureFormat::RGBA8, flags, nullptr, "staging_buffer");
gpu::copy(staging, gbs[0]);
gpu::readTexture(staging, gpu::TextureFormat::RGBA8, Span((u8*)m_gb0->begin(), m_gb0->byte_size()));
gpu::readTexture(staging, Span((u8*)m_gb0->begin(), m_gb0->byte_size()));
gpu::copy(staging, gbs[1]);
gpu::readTexture(staging, gpu::TextureFormat::RGBA8, Span((u8*)m_gb1->begin(), m_gb1->byte_size()));
gpu::readTexture(staging, Span((u8*)m_gb1->begin(), m_gb1->byte_size()));
gpu::destroy(staging);
gpu::destroy(ub);

View file

@ -2419,7 +2419,7 @@ struct LightProbeGridPlugin final : public PropertyGrid::IPlugin {
header.width = m_grid.resolution.x;
header.height = m_grid.resolution.y;
header.depth = m_grid.resolution.z;
header.channels_count = sh_idx == 6 ? 3 : 4;
header.channels_count = 4;
header.channel_type = RawTextureHeader::ChannelType::FLOAT;
file.write(&header, sizeof(header));
const u32 c0 = (sh_idx * 4 + 0) / 3;
@ -2432,10 +2432,11 @@ struct LightProbeGridPlugin final : public PropertyGrid::IPlugin {
const u32 c30 = (sh_idx * 4 + 3) % 3;
if (sh_idx == 6) {
for (u32 i = 0; i < m_total; ++i) {
Vec3 v;
Vec4 v;
v.x = (&m_result[i].coefs[c0].x)[c00];
v.y = (&m_result[i].coefs[c1].x)[c10];
v.z = (&m_result[i].coefs[c2].x)[c20];
v.w = 0;
file.write(&v, sizeof(v));
}
}

View file

@ -1226,7 +1226,6 @@ static struct {
{TextureFormat::RGBA8, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE},
{TextureFormat::RGBA16, GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT},
{TextureFormat::RGBA16F, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT},
{TextureFormat::RGB32F, GL_RGB32F, GL_RGB, GL_FLOAT},
{TextureFormat::RGBA32F, GL_RGBA32F, GL_RGBA, GL_FLOAT},
{TextureFormat::R16F, GL_R16F, GL_RED, GL_HALF_FLOAT},
{TextureFormat::R8, GL_R8, GL_RED, GL_UNSIGNED_BYTE},
@ -1894,7 +1893,7 @@ void copy(TextureHandle dst_handle, TextureHandle src_handle) {
CHECK_GL(glCopyImageSubData(src.handle, src.target, 0, 0, 0, 0, dst.handle, dst.target, 0, 0, 0, 0, src.width, src.height, 1));
}
void readTexture(TextureHandle texture, TextureFormat format, Span<u8> buf)
void readTexture(TextureHandle texture, Span<u8> buf)
{
checkThread();
@ -1902,7 +1901,7 @@ void readTexture(TextureHandle texture, TextureFormat format, Span<u8> buf)
const GLuint handle = t.handle;
for (int i = 0; i < sizeof(s_texture_formats) / sizeof(s_texture_formats[0]); ++i) {
if (s_texture_formats[i].format == format) {
if (s_texture_formats[i].gl_internal == t.format) {
const auto& f = s_texture_formats[i];
CHECK_GL(glGetTextureImage(handle, 0, f.gl_format, f.type, buf.length(), buf.begin()));
return;

View file

@ -118,7 +118,6 @@ enum class TextureFormat : u32 {
RGBA8,
RGBA16,
RGBA16F,
RGB32F,
RGBA32F,
R16F,
R16,
@ -235,7 +234,7 @@ void* map(BufferHandle buffer, size_t size);
void unmap(BufferHandle buffer);
void bindUniformBuffer(u32 index, BufferHandle buffer, size_t offset, size_t size);
void copy(TextureHandle dst, TextureHandle src);
void readTexture(TextureHandle texture, TextureFormat format, Span<u8> buf);
void readTexture(TextureHandle texture, Span<u8> buf);
TextureInfo getTextureInfo(const void* data);
void queryTimestamp(QueryHandle query);
u64 getQueryResult(QueryHandle query);

View file

@ -1021,7 +1021,6 @@ struct PipelineImpl final : Pipeline
{"srgb", gpu::TextureFormat::SRGB},
{"rgba16", gpu::TextureFormat::RGBA16},
{"rgba16f", gpu::TextureFormat::RGBA16F},
{"rgb32f", gpu::TextureFormat::RGB32F},
{"rgba32f", gpu::TextureFormat::RGBA32F},
{"r16f", gpu::TextureFormat::R16F},
{"r16", gpu::TextureFormat::R16},
@ -3425,7 +3424,7 @@ struct PipelineImpl final : Pipeline
const u32 flags = u32(gpu::TextureFlags::NO_MIPS) | u32(gpu::TextureFlags::READBACK);
gpu::createTexture(staging, w, h, 1, gpu::TextureFormat::RGBA8, flags, nullptr, "staging_buffer");
gpu::copy(staging, handle);
gpu::readTexture(staging, gpu::TextureFormat::RGBA8, Span((u8*)pixels.begin(), pixels.byte_size()));
gpu::readTexture(staging, Span((u8*)pixels.begin(), pixels.byte_size()));
gpu::destroy(staging);
OS::OutputFile file;

View file

@ -577,7 +577,7 @@ struct RendererImpl final : public Renderer
const u32 flags = u32(gpu::TextureFlags::NO_MIPS) | u32(gpu::TextureFlags::READBACK);
gpu::createTexture(staging, w, h, 1, out_format, flags, nullptr, "staging_buffer");
gpu::copy(staging, handle);
gpu::readTexture(staging, out_format, buf);
gpu::readTexture(staging, buf);
gpu::destroy(staging);
gpu::popDebugGroup();
}

View file

@ -353,7 +353,6 @@ static bool loadRaw(Texture& texture, InputMemoryStream& file, IAllocator& alloc
texture.bytes_per_pixel = sizeof(float) * header.channels_count;
switch (header.channels_count) {
case 1: format = gpu::TextureFormat::R32F; break;
case 3: format = gpu::TextureFormat::RGB32F; break;
case 4: format = gpu::TextureFormat::RGBA32F; break;
default: ASSERT(false); return false;
}