mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-09-05 09:05:54 +00:00
material asset changes for render targets
This commit is contained in:
parent
4b9e68ec40
commit
9abf213004
2 changed files with 41 additions and 3 deletions
|
@ -708,10 +708,40 @@ bool RasterMaterialData::FromJson(const CustomAssetLibrary::AssetID& asset_id,
|
|||
auto& pixel_texture_json_obj = pixel_texture_json.get<picojson::object>();
|
||||
|
||||
TextureSamplerValue sampler_value;
|
||||
TextureSamplerValue::FromJson(pixel_texture_json_obj, &sampler_value);
|
||||
if (!TextureSamplerValue::FromJson(pixel_texture_json_obj, &sampler_value))
|
||||
return false;
|
||||
data->pixel_textures.push_back(std::move(sampler_value));
|
||||
}
|
||||
|
||||
const auto render_targets_iter = json.find("render_targets");
|
||||
if (render_targets_iter == json.end())
|
||||
{
|
||||
ERROR_LOG_FMT(VIDEO, "Asset '{}' failed to parse json, 'render_targets' not found", asset_id);
|
||||
return false;
|
||||
}
|
||||
if (!render_targets_iter->second.is<picojson::array>())
|
||||
{
|
||||
ERROR_LOG_FMT(VIDEO,
|
||||
"Asset '{}' failed to parse json, 'render_targets' is not the right json type",
|
||||
asset_id);
|
||||
return false;
|
||||
}
|
||||
const auto& render_targets_array = render_targets_iter->second.get<picojson::array>();
|
||||
if (!std::ranges::all_of(render_targets_array, [](const picojson::value& json_data) {
|
||||
return json_data.is<std::string>();
|
||||
}))
|
||||
{
|
||||
ERROR_LOG_FMT(VIDEO, "Asset '{}' failed to parse json, 'render_targets' must contain strings",
|
||||
asset_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const auto& render_target_json : render_targets_array)
|
||||
{
|
||||
std::string render_target_str = render_target_json.to_str();
|
||||
data->render_targets.push_back(std::move(render_target_str));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -838,6 +868,13 @@ void RasterMaterialData::ToJson(picojson::object* obj, const RasterMaterialData&
|
|||
json_textures.emplace_back(std::move(json_texture));
|
||||
}
|
||||
json_obj.emplace("pixel_textures", json_textures);
|
||||
|
||||
picojson::array json_render_targets;
|
||||
for (const auto& render_target : data.render_targets)
|
||||
{
|
||||
json_render_targets.emplace_back(render_target);
|
||||
}
|
||||
json_obj.emplace("render_targets", json_render_targets);
|
||||
}
|
||||
|
||||
CustomAssetLibrary::LoadInfo MaterialAsset::LoadImpl(const CustomAssetLibrary::AssetID& asset_id)
|
||||
|
|
|
@ -71,8 +71,8 @@ struct RasterMaterialData
|
|||
static bool FromJson(const CustomAssetLibrary::AssetID& asset_id, const picojson::object& json,
|
||||
RasterMaterialData* data);
|
||||
static void ToJson(picojson::object* obj, const RasterMaterialData& data);
|
||||
std::string shader_asset;
|
||||
std::string next_material_asset;
|
||||
CustomAssetLibrary::AssetID shader_asset;
|
||||
CustomAssetLibrary::AssetID next_material_asset;
|
||||
std::vector<MaterialProperty2> vertex_properties;
|
||||
std::vector<MaterialProperty2> pixel_properties;
|
||||
|
||||
|
@ -81,6 +81,7 @@ struct RasterMaterialData
|
|||
std::optional<BlendingState> blending_state;
|
||||
|
||||
std::vector<TextureSamplerValue> pixel_textures;
|
||||
std::vector<CustomAssetLibrary::AssetID> render_targets;
|
||||
};
|
||||
|
||||
class RasterMaterialAsset final : public CustomLoadableAsset<RasterMaterialData>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue