mirror of
				https://git.suyu.dev/suyu/suyu
				synced 2025-10-31 16:09:03 -05:00 
			
		
		
		
	GPU: Implement sampling multiple textures in the generated glsl shaders.
All tested games that use a single texture show no regression. Only Texture2D textures are supported right now, each shader gets its own "tex_fs/vs/gs" sampler array to maintain independent textures between shader stages, the textures themselves are reused if possible.
This commit is contained in:
		| @@ -354,6 +354,40 @@ std::vector<Texture::FullTextureInfo> Maxwell3D::GetStageTextures(Regs::ShaderSt | ||||
|     return textures; | ||||
| } | ||||
|  | ||||
| Texture::FullTextureInfo Maxwell3D::GetStageTexture(Regs::ShaderStage stage, size_t offset) const { | ||||
|     auto& shader = state.shader_stages[static_cast<size_t>(stage)]; | ||||
|     auto& tex_info_buffer = shader.const_buffers[regs.tex_cb_index]; | ||||
|     ASSERT(tex_info_buffer.enabled && tex_info_buffer.address != 0); | ||||
|  | ||||
|     GPUVAddr tex_info_address = tex_info_buffer.address + offset * sizeof(Texture::TextureHandle); | ||||
|  | ||||
|     ASSERT(tex_info_address < tex_info_buffer.address + tex_info_buffer.size); | ||||
|  | ||||
|     boost::optional<VAddr> tex_address_cpu = memory_manager.GpuToCpuAddress(tex_info_address); | ||||
|     Texture::TextureHandle tex_handle{Memory::Read32(*tex_address_cpu)}; | ||||
|  | ||||
|     Texture::FullTextureInfo tex_info{}; | ||||
|     tex_info.index = static_cast<u32>(offset); | ||||
|  | ||||
|     // Load the TIC data. | ||||
|     if (tex_handle.tic_id != 0) { | ||||
|         tex_info.enabled = true; | ||||
|  | ||||
|         auto tic_entry = GetTICEntry(tex_handle.tic_id); | ||||
|         // TODO(Subv): Workaround for BitField's move constructor being deleted. | ||||
|         std::memcpy(&tex_info.tic, &tic_entry, sizeof(tic_entry)); | ||||
|     } | ||||
|  | ||||
|     // Load the TSC data | ||||
|     if (tex_handle.tsc_id != 0) { | ||||
|         auto tsc_entry = GetTSCEntry(tex_handle.tsc_id); | ||||
|         // TODO(Subv): Workaround for BitField's move constructor being deleted. | ||||
|         std::memcpy(&tex_info.tsc, &tsc_entry, sizeof(tsc_entry)); | ||||
|     } | ||||
|  | ||||
|     return tex_info; | ||||
| } | ||||
|  | ||||
| u32 Maxwell3D::GetRegisterValue(u32 method) const { | ||||
|     ASSERT_MSG(method < Regs::NUM_REGS, "Invalid Maxwell3D register"); | ||||
|     return regs.reg_array[method]; | ||||
|   | ||||
| @@ -664,6 +664,9 @@ public: | ||||
|     /// Returns a list of enabled textures for the specified shader stage. | ||||
|     std::vector<Texture::FullTextureInfo> GetStageTextures(Regs::ShaderStage stage) const; | ||||
|  | ||||
|     /// Returns the texture information for a specific texture in a specific shader stage. | ||||
|     Texture::FullTextureInfo GetStageTexture(Regs::ShaderStage stage, size_t offset) const; | ||||
|  | ||||
|     /// Returns whether the specified shader stage is enabled or not. | ||||
|     bool IsShaderStageEnabled(Regs::ShaderStage stage) const; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Subv
					Subv