Skip to content

add ycbcr support to json_gen layer - #17

Open
zangold wants to merge 1 commit into
sc_mainfrom
ycbcr-support
Open

add ycbcr support to json_gen layer#17
zangold wants to merge 1 commit into
sc_mainfrom
ycbcr-support

Conversation

@zangold

@zangold zangold commented Aug 12, 2025

Copy link
Copy Markdown

No description provided.


if (!ycbcrFeatures.samplerYcbcrConversion) {
std::cout << "YCbCr conversion not supported, skipping YCbCr sampler test" << std::endl;
return VK_SUCCESS;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this VK_SUCCESS and print is OK behavior for feature not supported in the test jsonGenLayerTests/main.cpp .
comment here to confirm.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on further reflection, this would cause tests to fail if the test system doesn't support ycbcr, since UUID & JSON output would change.

We would probably need to accept multiple pipeline UUIDs / golden JSONs. It looks like the CI runs fail because of other issues, and (IIUC) this code is intended to be largely rewritten soon. Should we resolve that before merging this patch, or just ignore it for now?

#define INDENT(sz) s_num_spaces += (sz);

// Forward declaration for layer-provided accessor used by serializer
int GetYcbcrConversionIdForPrint(VkSamplerYcbcrConversion conversion);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print_VkSamplerYcbcrConversion calls the declared function GetYcbcrConversionIdForPrint .
will the symbol get resolved at link time, or at dynamic load time ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be resolved at link time. IIRC, LLM code generation put the implementation in vulkan_json_layer.hpp because s_pipe wasn't accessible from vulkan_json_data.hpp. But, if vulkan_json_data.hpp gets reused by CTS, that'll probably cause problems too. :/

I'll think about this more tomorrow.

Comment thread layersvt/vulkan_json_data.hpp Outdated
}
} else {
if (commaNeeded)
_OUT << "\"NULL\"" << "," << std::endl;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review-code.mdc comment, between these lines :

  •          _OUT << "\"\"" << "," << std::endl;
    
  •          _OUT << "\"NULL\"" << "," << std::endl;
    

Inconsistent Error Handling: The function returns different values for invalid conversion IDs (empty string vs "NULL").
Evidence: Lines 14537-40 return empty string, while lines 14559-62 return "NULL"
Proposed Comment to be Included: Standardize error return values for invalid YCbCr conversion IDs (use either empty string or "NULL" consistently)
Justification for Commenting: This is valid (inconsistent error handling exists), critical (affects API consistency), actionable (can standardize return values), and restrained in scope (only affects error return values)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

standardized error case to empty string in both cases

Comment thread scripts/json_gen_generator.py Outdated
while (pNext != nullptr) {{
if (pNext->sType == VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO) {{
const VkSamplerYcbcrConversionInfo* ycbcrInfo = reinterpret_cast<const VkSamplerYcbcrConversionInfo*>(pNext);
vk_json::s_pipe.setYcbcrSamplerConversionAssociation(*pSampler, ycbcrInfo->conversion);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setSamplerInfo , which this vkCreateSampler template calls above , also calls setYcbcrSamplerConversionAssociation .
in vulkan_json_layer.hpp :

             // Store a copy of the YCbCr conversion info
            m_samplerYcbcrInfoMap.insert(std::make_pair(*pSampler, *ycbcrInfo));
            // Update the sampler create info to point to our persistent copy
            samplerInfo.pNext = &m_samplerYcbcrInfoMap[*pSampler];
            // Also store the association
            setYcbcrSamplerConversionAssociation(*pSampler, ycbcrInfo->conversion);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the redundant code in json_gen_generator.py, thanks for spotting this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants