Skip to content

Commit

Permalink
fixup! Initial implementation of yuv444in420 encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
ns6089 committed Jun 26, 2024
1 parent acbc5d4 commit b081409
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/platform/windows/display_vram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,31 +462,33 @@ namespace platf::dxgi {
device_ctx->Draw(9, 0); // vertex shader spreads 9 vertices across 3 viewports
}
else if (recombine_yuv444_into_yuv420) {
device_ctx->OMSetRenderTargets(1, &nv12_Y_rt, nullptr);
device_ctx->VSSetShader(scene_vs.get(), nullptr, 0);
device_ctx->PSSetShader(img.format == DXGI_FORMAT_R16G16B16A16_FLOAT ? convert_Y_fp16_ps.get() : convert_Y_ps.get(), nullptr, 0);

if (!rt_cleared) {
// TODO: clear
rt_cleared = true;
}

assert(outY_index_buffer);
assert(outY_input_layout && outY_index_buffer && outY_vertex_buffer && outY_vertex_buffer_stride);
assert(outUV_input_layout && outUV_index_buffer && outUV_vertex_buffer && outUV_vertex_buffer_stride);

device_ctx->OMSetRenderTargets(1, &nv12_Y_rt, nullptr);
device_ctx->VSSetShader(scene_vs.get(), nullptr, 0);
device_ctx->PSSetShader(img.format == DXGI_FORMAT_R16G16B16A16_FLOAT ? convert_Y_fp16_ps.get() : convert_Y_ps.get(), nullptr, 0);
assert(outYUVinY_views.size() == 3);
device_ctx->RSSetViewports(outYUVinY_views.size(), outYUVinY_views.data());
device_ctx->IASetInputLayout(outY_input_layout.get());
device_ctx->IASetIndexBuffer(outY_index_buffer.get(), DXGI_FORMAT_R32_UINT, 0);
auto y_buffer = outY_vertex_buffer.get();
UINT y_offset = 0;
device_ctx->IASetVertexBuffers(0, 1, &y_buffer, &outY_vertex_buffer_stride, &y_offset);
UINT y_buffer_offset = 0;
device_ctx->IASetVertexBuffers(0, 1, &outY_vertex_buffer, &outY_vertex_buffer_stride, &y_buffer_offset);
device_ctx->DrawIndexed(outY_index_buffer_size, 0, 0);

assert(outUV_index_buffer);
device_ctx->OMSetRenderTargets(1, &nv12_UV_rt, nullptr);
device_ctx->VSSetShader(convert_UV_vs.get(), nullptr, 0);
device_ctx->PSSetShader(img.format == DXGI_FORMAT_R16G16B16A16_FLOAT ? convert_UV_fp16_ps.get() : convert_UV_ps.get(), nullptr, 0);
device_ctx->RSSetViewports(1, &outUV_view);
device_ctx->IASetInputLayout(outUV_input_layout.get());
device_ctx->IASetIndexBuffer(outUV_index_buffer.get(), DXGI_FORMAT_R32_UINT, 0);
auto uv_buffer = outUV_vertex_buffer.get();
UINT uv_offset = 0;
device_ctx->IASetVertexBuffers(0, 1, &uv_buffer, &outUV_vertex_buffer_stride, &uv_offset);
UINT uv_buffer_offset = 0;
device_ctx->IASetVertexBuffers(0, 1, &outUV_vertex_buffer, &outUV_vertex_buffer_stride, &uv_buffer_offset);
device_ctx->DrawIndexed(outUV_index_buffer_size, 0, 0);
}
else {
Expand Down

0 comments on commit b081409

Please sign in to comment.