Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the new GPU VA context class to handle VA connections to GPU. Removed the hard coded HW decoder capability info. #415

Merged
merged 23 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
407b3b7
* rocDecode: Removed the hard coded HW decoder capability info.
jeffqjiangNew Aug 29, 2024
4cc2d2f
Merge branch 'develop' into jj/decode_cap
jeffqjiangNew Sep 16, 2024
ce04289
* rocDecode: Added number of decoder prob and a few missing tear down…
jeffqjiangNew Sep 19, 2024
5dae726
Merge branch 'develop' into jj/decode_cap
jeffqjiangNew Nov 29, 2024
25c9eb2
Merge branch 'develop' into jj/decode_cap
jeffqjiangNew Dec 3, 2024
d43a7a4
Merge branch 'develop' into jj/decode_cap
jeffqjiangNew Dec 5, 2024
18e8c5a
Merge branch 'jj/decode_cap' of github.com:jeffqjiangNew/rocDecode in…
jeffqjiangNew Dec 6, 2024
3ba4914
Merge branch 'develop' into jj/decode_cap
jeffqjiangNew Dec 6, 2024
f999c80
* rocDecode/HW cap change: Added a new singleton class, GpuVaContext,…
jeffqjiangNew Dec 16, 2024
f093f1a
Merge branch 'develop' into jj/decode_cap
jeffqjiangNew Dec 16, 2024
2741095
* rocDecode/HW caps: Removed GpuVaContext class out of vaapi_videodec…
jeffqjiangNew Dec 16, 2024
32af3f6
* rocDecode/HW caps: Fixed a crash issue with multi-thread cases. Cal…
jeffqjiangNew Dec 17, 2024
5699aac
* rocDecode/HW caps: Added multi-GPU support.
jeffqjiangNew Dec 20, 2024
b61ec92
* rocDecode/HW cap: Moved GpuVaContext class implementation back to V…
jeffqjiangNew Dec 26, 2024
4736a92
Merge branch 'develop' into jj/decode_cap
jeffqjiangNew Dec 30, 2024
bac0d57
Merge branch 'develop' into jj/decode_cap
jeffqjiangNew Jan 5, 2025
719c31b
Merge branch 'develop' into jj/decode_cap
kiritigowda Jan 6, 2025
a95054f
* rocDecode/HW cap: Added changed based on review comments.
jeffqjiangNew Jan 8, 2025
b548096
Merge branch 'jj/decode_cap' of github.com:jeffqjiangNew/rocDecode in…
jeffqjiangNew Jan 8, 2025
3239608
Merge branch 'develop' into jj/decode_cap
jeffqjiangNew Jan 8, 2025
cd8d527
* rocDecode/HW cap: Added changes based on review comments.
jeffqjiangNew Jan 8, 2025
954e12b
Merge branch 'develop' into jj/decode_cap
jeffqjiangNew Jan 9, 2025
cc6c46d
* rocDecode/HW cap: GPU VA context class name change based on review …
jeffqjiangNew Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions src/rocdecode/roc_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ RocDecoder::RocDecoder(RocDecoderCreateInfo& decoder_create_info): va_video_deco

rocDecStatus RocDecoder::InitializeDecoder() {
rocDecStatus rocdec_status = ROCDEC_SUCCESS;
rocdec_status = InitHIP(decoder_create_info_.device_id);
if (rocdec_status != ROCDEC_SUCCESS) {
ERR("Failed to initilize the HIP.");
return rocdec_status;
}
if (decoder_create_info_.num_decode_surfaces < 1) {
ERR("Invalid number of decode surfaces.");
return ROCDEC_INVALID_PARAMETER;
Expand All @@ -58,8 +53,7 @@ RocDecoder::RocDecoder(RocDecoderCreateInfo& decoder_create_info): va_video_deco
for (auto i = 0; i < hip_interop_.size(); i++) {
memset((void *)&hip_interop_[i], 0, sizeof(hip_interop_[i]));
}
std::string gpu_uuid(hip_dev_prop_.uuid.bytes, sizeof(hip_dev_prop_.uuid.bytes));
rocdec_status = va_video_decoder_.InitializeDecoder(hip_dev_prop_.name, hip_dev_prop_.gcnArchName, gpu_uuid);
rocdec_status = va_video_decoder_.InitializeDecoder();
if (rocdec_status != ROCDEC_SUCCESS) {
ERR("Failed to initilize the VAAPI Video decoder.");
return rocdec_status;
Expand Down Expand Up @@ -186,16 +180,3 @@ rocDecStatus RocDecoder::FreeVideoFrame(int pic_idx) {

return ROCDEC_SUCCESS;
}


rocDecStatus RocDecoder::InitHIP(int device_id) {
CHECK_HIP(hipGetDeviceCount(&num_devices_));
if (num_devices_ < 1) {
ERR("Didn't find any GPU.");
return ROCDEC_DEVICE_INVALID;
}
CHECK_HIP(hipSetDevice(device_id));
CHECK_HIP(hipGetDeviceProperties(&hip_dev_prop_, device_id));

return ROCDEC_SUCCESS;
}
10 changes: 0 additions & 10 deletions src/rocdecode/roc_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ THE SOFTWARE.
#include <hip/hip_runtime.h>
#include "vaapi/vaapi_videodecoder.h"

#define CHECK_HIP(call) {\
hipError_t hip_status = call;\
if (hip_status != hipSuccess) {\
std::cout << "HIP failure: " << #call << " failed with 'status: " << hipGetErrorName(hip_status) << "' at " << __FILE__ << ":" << __LINE__ << std::endl;\
return ROCDEC_RUNTIME_ERROR;\
}\
}

struct HipInteropDeviceMem {
hipExternalMemory_t hip_ext_mem; // Interface to the vaapi-hip interop
uint8_t* hip_mapped_device_mem; // Mapped device memory for the YUV plane
Expand All @@ -63,11 +55,9 @@ class RocDecoder {
rocDecStatus GetVideoFrame(int pic_idx, void *dev_mem_ptr[3], uint32_t horizontal_pitch[3], RocdecProcParams *vid_postproc_params);

private:
rocDecStatus InitHIP(int device_id);
rocDecStatus FreeVideoFrame(int pic_idx);
int num_devices_;
RocDecoderCreateInfo decoder_create_info_;
VaapiVideoDecoder va_video_decoder_;
hipDeviceProp_t hip_dev_prop_;
std::vector<HipInteropDeviceMem> hip_interop_;
};
141 changes: 0 additions & 141 deletions src/rocdecode/roc_decoder_caps.h

This file was deleted.

32 changes: 8 additions & 24 deletions src/rocdecode/rocdecode_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ THE SOFTWARE.
*/
#include "dec_handle.h"
#include "rocdecode.h"
#include "roc_decoder_caps.h"
#include "vaapi_videodecoder.h"
#include "../commons.h"

namespace rocdecode {
Expand Down Expand Up @@ -72,30 +72,14 @@ rocDecGetDecoderCaps(RocdecDecodeCaps *pdc) {
if (pdc == nullptr) {
return ROCDEC_INVALID_PARAMETER;
}
hipError_t hip_status = hipSuccess;
int num_devices = 0;
hipDeviceProp_t hip_dev_prop;
hip_status = hipGetDeviceCount(&num_devices);
if (hip_status != hipSuccess) {
ERR("ERROR: hipGetDeviceCount failed!" + TOSTR(hip_status));
return ROCDEC_DEVICE_INVALID;
VaContext& va_ctx = VaContext::GetInstance();
rocDecStatus ret = ROCDEC_SUCCESS;
if ((ret = va_ctx.CheckDecCapForCodecType(pdc)) != ROCDEC_SUCCESS) {
ERR("Failed to obtain decoder capabilities from driver.");
return ret;
} else {
return ROCDEC_SUCCESS;
}
if (num_devices < 1) {
ERR("ERROR: didn't find any GPU!");
return ROCDEC_DEVICE_INVALID;
}
if (pdc->device_id >= num_devices) {
ERR("ERROR: the requested device_id is not found! ");
return ROCDEC_DEVICE_INVALID;
}
hip_status = hipGetDeviceProperties(&hip_dev_prop, pdc->device_id);
if (hip_status != hipSuccess) {
ERR("ERROR: hipGetDeviceProperties for device (" +TOSTR(pdc->device_id) + " ) failed! (" + TOSTR(hip_status) + ")" );
return ROCDEC_DEVICE_INVALID;
}

RocDecVcnCodecSpec& vcn_codec_spec = RocDecVcnCodecSpec::GetInstance();
return vcn_codec_spec.GetDecoderCaps(hip_dev_prop.gcnArchName, pdc);
}

/*****************************************************************************************************/
Expand Down
Loading