Skip to content

Commit

Permalink
fixup! Initial implementation of yuv444 encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
ns6089 committed Aug 1, 2024
1 parent af024cb commit cd06345
Showing 1 changed file with 27 additions and 37 deletions.
64 changes: 27 additions & 37 deletions src/platform/windows/display_vram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,32 @@ namespace platf::dxgi {

int
init(std::shared_ptr<platf::display_t> display, adapter_t::pointer adapter_p, pix_fmt_e pix_fmt) {
switch (pix_fmt) {
case pix_fmt_e::nv12:
format = DXGI_FORMAT_NV12;
break;

Check warning on line 618 in src/platform/windows/display_vram.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/windows/display_vram.cpp#L616-L618

Added lines #L616 - L618 were not covered by tests

case pix_fmt_e::p010:
format = DXGI_FORMAT_P010;
break;

Check warning on line 622 in src/platform/windows/display_vram.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/windows/display_vram.cpp#L620-L622

Added lines #L620 - L622 were not covered by tests

case pix_fmt_e::ayuv:
format = DXGI_FORMAT_AYUV;
break;

Check warning on line 626 in src/platform/windows/display_vram.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/windows/display_vram.cpp#L624-L626

Added lines #L624 - L626 were not covered by tests

case pix_fmt_e::yuv444p16:
format = DXGI_FORMAT_R16_UINT;
break;

Check warning on line 630 in src/platform/windows/display_vram.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/windows/display_vram.cpp#L628-L630

Added lines #L628 - L630 were not covered by tests

case pix_fmt_e::y410:
format = DXGI_FORMAT_Y410;
break;

Check warning on line 634 in src/platform/windows/display_vram.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/windows/display_vram.cpp#L632-L634

Added lines #L632 - L634 were not covered by tests

default:

Check warning on line 636 in src/platform/windows/display_vram.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/windows/display_vram.cpp#L636

Added line #L636 was not covered by tests
BOOST_LOG(error) << "D3D11 backend doesn't support pixel format: " << from_pix_fmt(pix_fmt);
return -1;

Check warning on line 638 in src/platform/windows/display_vram.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/windows/display_vram.cpp#L638

Added line #L638 was not covered by tests
}

D3D_FEATURE_LEVEL featureLevels[] {
D3D_FEATURE_LEVEL_11_1,
D3D_FEATURE_LEVEL_11_0,
Expand Down Expand Up @@ -650,32 +676,6 @@ namespace platf::dxgi {
BOOST_LOG(warning) << "Failed to increase encoding GPU thread priority. Please run application as administrator for optimal performance.";
}

switch (pix_fmt) {
case pix_fmt_e::nv12:
format = DXGI_FORMAT_NV12;
break;

case pix_fmt_e::p010:
format = DXGI_FORMAT_P010;
break;

case pix_fmt_e::ayuv:
format = DXGI_FORMAT_AYUV;
break;

case pix_fmt_e::yuv444p16:
format = DXGI_FORMAT_R16_UINT;
break;

case pix_fmt_e::y410:
format = DXGI_FORMAT_Y410;
break;

default:
BOOST_LOG(error) << "DXGI backend doesn't support requested pixel format";
return -1;
}

#define create_vertex_shader_helper(x, y) \
if (FAILED(status = device->CreateVertexShader(x->GetBufferPointer(), x->GetBufferSize(), nullptr, &y))) { \
BOOST_LOG(error) << "Failed to create vertex shader " << #x << ": " << util::log_hex(status); \
Expand Down Expand Up @@ -1887,20 +1887,10 @@ namespace platf::dxgi {

std::unique_ptr<avcodec_encode_device_t>
display_vram_t::make_avcodec_encode_device(pix_fmt_e pix_fmt) {
if (pix_fmt != platf::pix_fmt_e::nv12 && pix_fmt != platf::pix_fmt_e::p010) {
BOOST_LOG(error) << "display_vram_t doesn't support pixel format ["sv << from_pix_fmt(pix_fmt) << ']';

return nullptr;
}

auto device = std::make_unique<d3d_avcodec_encode_device_t>();

auto ret = device->init(shared_from_this(), adapter.get(), pix_fmt);

if (ret) {
if (device->init(shared_from_this(), adapter.get(), pix_fmt) != 0) {
return nullptr;
}

return device;
}

Expand Down

0 comments on commit cd06345

Please sign in to comment.