Skip to content

[WIP] spirv-opt: Fix when ConvertToHalfPass relaxes a image operand#6480

Open
spencer-lunarg wants to merge 1 commit intoKhronosGroup:mainfrom
spencer-lunarg:spencer-lunarg-convert-half-image-operand
Open

[WIP] spirv-opt: Fix when ConvertToHalfPass relaxes a image operand#6480
spencer-lunarg wants to merge 1 commit intoKhronosGroup:mainfrom
spencer-lunarg:spencer-lunarg-convert-half-image-operand

Conversation

@spencer-lunarg
Copy link
Contributor

My attempt at solving #6476

Copy link
Collaborator

@s-perron s-perron left a comment

Choose a reason for hiding this comment

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

Please add some tests as well.

Comment on lines +288 to +306
uint32_t dy_update_operand = next_operand++;
const uint32_t dy_ref_id = inst->GetSingleWordOperand(dy_update_operand);
Instruction* dy_ref_inst = get_def_use_mgr()->GetDef(dy_ref_id);
Instruction* dy_type_inst =
get_def_use_mgr()->GetDef(dy_ref_inst->type_id());
assert(dy_type_inst->opcode() == spv::Op::OpTypeFloat);
if (dy_type_inst->GetSingleWordInOperand(0) != 32) {
Instruction* dy_cvt_inst =
builder.AddUnaryOp(float32_type, spv::Op::OpFConvert, ref_id);
if (dy_cvt_inst == nullptr) {
status_ = Status::Failure;
return false;
}
inst->SetOperand(dy_update_operand, {dy_cvt_inst->result_id()});
get_def_use_mgr()->AnalyzeInstUse(inst);
modified = true;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems to repeat a lot of the code above, could it be factored out into a function that modifies the given operand?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

debated about it, probably better, especially if a new operand is ever added doing something similar (or worse)

@spencer-lunarg
Copy link
Contributor Author

Please add some tests as well.

100%, just was trying to mock something up for Dan to verify it works before committing... could have marked this "Draft" I guess

@spencer-lunarg spencer-lunarg force-pushed the spencer-lunarg-convert-half-image-operand branch from 1c9f3b6 to 8e632a8 Compare January 5, 2026 22:26
@spencer-lunarg spencer-lunarg changed the title spirv-opt: Fix when ConvertToHalfPass relaxes a image operand [WIP] spirv-opt: Fix when ConvertToHalfPass relaxes a image operand Jan 5, 2026
@s-perron s-perron self-requested a review February 4, 2026 15:58
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.

2 participants