better gpu api for dx version
This commit is contained in:
parent
896630f941
commit
8d54c90b56
7 changed files with 27 additions and 30 deletions
|
@ -141,19 +141,6 @@ function lightPass(gbuffer0, gbuffer1, gbuffer2, gbuffer_depth, shadowmap, local
|
|||
endBlock()
|
||||
end
|
||||
|
||||
--[[
|
||||
beginBlock("local_lights")
|
||||
bindRenderbuffers({
|
||||
gbuffer0,
|
||||
gbuffer1,
|
||||
gbuffer2,
|
||||
gbuffer_depth,
|
||||
shadowmap
|
||||
}, 0)
|
||||
renderLocalLights("", local_light_shader, local_light_set)
|
||||
endBlock()
|
||||
]]--
|
||||
|
||||
return hdr_rb
|
||||
end
|
||||
|
||||
|
|
|
@ -862,9 +862,9 @@ struct CaptureImpostorJob : Renderer::RenderJob {
|
|||
gpu::TextureHandle staging = gpu::allocTextureHandle();
|
||||
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], 0);
|
||||
gpu::copy(staging, gbs[0]);
|
||||
gpu::readTexture(staging, 0, Span((u8*)m_gb0->begin(), m_gb0->byte_size()));
|
||||
gpu::copy(staging, gbs[1], 0);
|
||||
gpu::copy(staging, gbs[1]);
|
||||
gpu::readTexture(staging, 0, Span((u8*)m_gb1->begin(), m_gb1->byte_size()));
|
||||
gpu::destroy(staging);
|
||||
|
||||
|
|
|
@ -2821,6 +2821,8 @@ struct EnvironmentProbePlugin final : PropertyGrid::IPlugin
|
|||
}
|
||||
}
|
||||
|
||||
gpu::setFramebuffer(nullptr, 0, 0);
|
||||
|
||||
gpu::TextureHandle staging = gpu::allocTextureHandle();
|
||||
const u32 flags = u32(gpu::TextureFlags::IS_CUBE) | u32(gpu::TextureFlags::READBACK);
|
||||
gpu::createTexture(staging, size, size, 1, gpu::TextureFormat::RGBA32F, flags, nullptr, "staging_buffer");
|
||||
|
@ -2834,14 +2836,13 @@ struct EnvironmentProbePlugin final : PropertyGrid::IPlugin
|
|||
|
||||
Array<u8> tmp(m_app.getAllocator());
|
||||
tmp.resize(data_size);
|
||||
u8* tmp_ptr = tmp.begin();
|
||||
|
||||
mip_size = size;
|
||||
gpu::copy(staging, dst);
|
||||
u8* tmp_ptr = tmp.begin();
|
||||
for (u32 mip = 0; mip < roughness_levels; ++mip) {
|
||||
gpu::copy(staging, dst, mip);
|
||||
const u32 mip_size = size >> mip;
|
||||
gpu::readTexture(staging, mip, Span(tmp_ptr, mip_size * mip_size * sizeof(Vec4) * 6));
|
||||
tmp_ptr += mip_size * mip_size * sizeof(Vec4) * 6;
|
||||
mip_size >>= 1;
|
||||
}
|
||||
gpu::stopCapture();
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ struct Texture
|
|||
GLenum format;
|
||||
u32 width;
|
||||
u32 height;
|
||||
u32 flags;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1333,6 +1334,7 @@ bool loadTexture(TextureHandle handle, const void* input, int input_size, u32 fl
|
|||
t.target = is_cubemap ? GL_TEXTURE_CUBE_MAP : layers > 1 ? GL_TEXTURE_2D_ARRAY : GL_TEXTURE_2D;
|
||||
t.width = hdr.dwWidth;
|
||||
t.height = hdr.dwHeight;
|
||||
t.flags = flags;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1534,6 +1536,7 @@ bool createTexture(TextureHandle handle, u32 w, u32 h, u32 depth, TextureFormat
|
|||
t.format = internal_format;
|
||||
t.width = w;
|
||||
t.height = h;
|
||||
t.flags = flags;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1844,7 +1847,7 @@ bool isHomogenousDepth() { return false; }
|
|||
bool isOriginBottomLeft() { return true; }
|
||||
|
||||
|
||||
void copy(TextureHandle dst_handle, TextureHandle src_handle, u32 mip) {
|
||||
void copy(TextureHandle dst_handle, TextureHandle src_handle) {
|
||||
checkThread();
|
||||
Texture& dst = g_gpu.textures[dst_handle.value];
|
||||
Texture& src = g_gpu.textures[src_handle.value];
|
||||
|
@ -1853,14 +1856,20 @@ void copy(TextureHandle dst_handle, TextureHandle src_handle, u32 mip) {
|
|||
ASSERT(dst.width == src.width);
|
||||
ASSERT(dst.height == src.height);
|
||||
|
||||
const u32 w = maximum(src.width >> mip, 1);
|
||||
const u32 h = maximum(src.height >> mip, 1);
|
||||
u32 mip = 0;
|
||||
while ((src.width >> mip) != 0 || (src.height >> mip) != 0) {
|
||||
const u32 w = maximum(src.width >> mip, 1);
|
||||
const u32 h = maximum(src.height >> mip, 1);
|
||||
|
||||
if (src.target == GL_TEXTURE_CUBE_MAP) {
|
||||
CHECK_GL(glCopyImageSubData(src.handle, src.target, mip, 0, 0, 0, dst.handle, dst.target, mip, 0, 0, 0, w, h, 6));
|
||||
}
|
||||
else {
|
||||
CHECK_GL(glCopyImageSubData(src.handle, src.target, mip, 0, 0, 0, dst.handle, dst.target, mip, 0, 0, 0, w, h, 1));
|
||||
if (src.target == GL_TEXTURE_CUBE_MAP) {
|
||||
CHECK_GL(glCopyImageSubData(src.handle, src.target, mip, 0, 0, 0, dst.handle, dst.target, mip, 0, 0, 0, w, h, 6));
|
||||
}
|
||||
else {
|
||||
CHECK_GL(glCopyImageSubData(src.handle, src.target, mip, 0, 0, 0, dst.handle, dst.target, mip, 0, 0, 0, w, h, 1));
|
||||
}
|
||||
++mip;
|
||||
if (src.flags & (u32)TextureFlags::NO_MIPS) break;
|
||||
if (dst.flags & (u32)TextureFlags::NO_MIPS) break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@ void* map(BufferHandle buffer, size_t size);
|
|||
void unmap(BufferHandle buffer);
|
||||
void bindUniformBuffer(u32 ub_index, BufferHandle buffer, size_t size);
|
||||
void bindUniformBuffer(u32 ub_index, BufferGroupHandle group, size_t element_index);
|
||||
void copy(TextureHandle dst, TextureHandle src, u32 level);
|
||||
void copy(TextureHandle dst, TextureHandle src);
|
||||
void readTexture(TextureHandle texture, u32 mip, Span<u8> buf);
|
||||
TextureInfo getTextureInfo(const void* data);
|
||||
void queryTimestamp(QueryHandle query);
|
||||
|
|
|
@ -3703,7 +3703,7 @@ struct PipelineImpl final : Pipeline
|
|||
gpu::TextureHandle staging = gpu::allocTextureHandle();
|
||||
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, 0);
|
||||
gpu::copy(staging, handle);
|
||||
gpu::readTexture(staging, 0, Span((u8*)pixels.begin(), pixels.byte_size()));
|
||||
gpu::destroy(staging);
|
||||
|
||||
|
|
|
@ -653,7 +653,7 @@ struct RendererImpl final : Renderer
|
|||
gpu::TextureHandle staging = gpu::allocTextureHandle();
|
||||
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, 0);
|
||||
gpu::copy(staging, handle);
|
||||
gpu::readTexture(staging, 0, buf);
|
||||
gpu::destroy(staging);
|
||||
gpu::popDebugGroup();
|
||||
|
|
Loading…
Reference in a new issue