mirror of
https://github.com/izzy2lost/ppsspp.git
synced 2026-03-10 12:43:04 -07:00
[GPU/Common/DX9/GLES/Software] Object out of scope optimization for better codegeneration (lower level scope)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <array>
|
||||
|
||||
#include "Common/GPU/thin3d.h"
|
||||
#include "Common/StringUtils.h"
|
||||
@@ -29,7 +30,7 @@ std::string VertexShaderDesc(const VShaderID &id) {
|
||||
const char *uvprojModes[4] = { "TexProjPos ", "TexProjUV ", "TexProjNNrm ", "TexProjNrm " };
|
||||
desc << uvprojModes[uvprojMode];
|
||||
}
|
||||
const char *uvgModes[4] = { "UV ", "UVMtx ", "UVEnv ", "UVUnk " };
|
||||
static constexpr std::array<const char*, 4> uvgModes = { "UV ", "UVMtx ", "UVEnv ", "UVUnk " };
|
||||
int ls0 = id.Bits(VS_BIT_LS0, 2);
|
||||
int ls1 = id.Bits(VS_BIT_LS1, 2);
|
||||
|
||||
|
||||
@@ -1116,7 +1116,6 @@ bool TextureCacheCommon::MatchFramebuffer(
|
||||
|
||||
void TextureCacheCommon::SetTextureFramebuffer(const AttachCandidate &candidate) {
|
||||
VirtualFramebuffer *framebuffer = candidate.fb;
|
||||
FramebufferMatchInfo fbInfo = candidate.match;
|
||||
RasterChannel channel = candidate.channel;
|
||||
|
||||
if (candidate.match.reinterpret) {
|
||||
@@ -1132,6 +1131,7 @@ void TextureCacheCommon::SetTextureFramebuffer(const AttachCandidate &candidate)
|
||||
nextFramebufferTextureChannel_ = RASTER_COLOR;
|
||||
|
||||
if (framebufferManager_->UseBufferedRendering()) {
|
||||
FramebufferMatchInfo fbInfo = candidate.match;
|
||||
// Detect when we need to apply the horizontal texture swizzle.
|
||||
u64 depthUpperBits = (channel == RASTER_DEPTH && framebuffer->fb_format == GE_FORMAT_8888) ? ((gstate.getTextureAddress(0) & 0x600000) >> 20) : 0;
|
||||
bool needsDepthXSwizzle = depthUpperBits == 2;
|
||||
|
||||
@@ -148,7 +148,7 @@ void Lighter::Light(float colorOut0[4], float colorOut1[4], const float colorIn[
|
||||
Color4 diff = (lightDiff * *diffuse) * dot;
|
||||
|
||||
// Real PSP specular
|
||||
Vec3f toViewer(0, 0, 1);
|
||||
static const Vec3f toViewer(0, 0, 1);
|
||||
// Better specular
|
||||
// Vec3f toViewer = (viewer - pos).NormalizedOr001(cpu_info.bSSE4_1);
|
||||
|
||||
|
||||
@@ -619,7 +619,6 @@ void ClearCallback() {
|
||||
|
||||
static void FinishRecording() {
|
||||
// We're done - this was just to write the result out.
|
||||
Path filename = WriteRecording();
|
||||
commands.clear();
|
||||
pushbuf.clear();
|
||||
lastVRAM.clear();
|
||||
@@ -630,8 +629,10 @@ static void FinishRecording() {
|
||||
flipFinishAt = -1;
|
||||
lastEdramTrans = 0x400;
|
||||
|
||||
if (writeCallback)
|
||||
if (writeCallback) {
|
||||
Path filename = WriteRecording();
|
||||
writeCallback(filename);
|
||||
}
|
||||
writeCallback = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -594,7 +594,6 @@ VSShader *ShaderManagerDX9::ApplyShader(bool useHWTransform, bool useHWTessellat
|
||||
vs = new VSShader(device_, VSID, codeBuffer_, useHWTransform);
|
||||
}
|
||||
if (!vs || vs->Failed()) {
|
||||
auto gr = GetI18NCategory(I18NCat::GRAPHICS);
|
||||
if (!vs) {
|
||||
// TODO: Report this?
|
||||
ERROR_LOG(G3D, "Shader generation failed, falling back to software transform");
|
||||
@@ -602,6 +601,7 @@ VSShader *ShaderManagerDX9::ApplyShader(bool useHWTransform, bool useHWTessellat
|
||||
ERROR_LOG(G3D, "Shader compilation failed, falling back to software transform");
|
||||
}
|
||||
if (!g_Config.bHideSlowWarnings) {
|
||||
auto gr = GetI18NCategory(I18NCat::GRAPHICS);
|
||||
g_OSD.Show(OSDType::MESSAGE_ERROR, gr->T("hardware transform error - falling back to software"), 2.5f);
|
||||
}
|
||||
delete vs;
|
||||
|
||||
@@ -804,9 +804,9 @@ Shader *ShaderManagerGLES::ApplyVertexShader(bool useHWTransform, bool useHWTess
|
||||
// Vertex shader not in cache. Let's compile it.
|
||||
vs = CompileVertexShader(*VSID);
|
||||
if (!vs) {
|
||||
auto gr = GetI18NCategory(I18NCat::GRAPHICS);
|
||||
ERROR_LOG(G3D, "Vertex shader generation failed, falling back to software transform");
|
||||
if (!g_Config.bHideSlowWarnings) {
|
||||
auto gr = GetI18NCategory(I18NCat::GRAPHICS);
|
||||
g_OSD.Show(OSDType::MESSAGE_ERROR, gr->T("hardware transform error - falling back to software"), 2.5f);
|
||||
}
|
||||
|
||||
|
||||
@@ -281,10 +281,11 @@ static inline float Dot33(const Vec3f &a, const Vec3f &b) {
|
||||
template <bool useSSE4>
|
||||
static void ProcessSIMD(VertexData &vertex, const WorldCoords &worldpos, const WorldCoords &worldnormal, const State &state) {
|
||||
// Lighting blending rounds using the half offset method (like alpha blend.)
|
||||
const Vec4<int> ones = Vec4<int>::AssignToAll(1);
|
||||
Vec4<int> colorFactor;
|
||||
if (state.colorForAmbient || state.colorForDiffuse || state.colorForSpecular)
|
||||
if (state.colorForAmbient || state.colorForDiffuse || state.colorForSpecular) {
|
||||
const Vec4<int> ones = Vec4<int>::AssignToAll(1);
|
||||
colorFactor = LightColorFactor(vertex.color0, ones);
|
||||
}
|
||||
|
||||
Vec4<int> mec = Vec4<int>::FromRGBA(gstate.getMaterialEmissive());
|
||||
|
||||
|
||||
@@ -1406,7 +1406,6 @@ void DrawRectangle(const VertexData &v0, const VertexData &v1, const BinCoords &
|
||||
void DrawPoint(const VertexData &v0, const BinCoords &range, const RasterizerState &state) {
|
||||
ScreenCoords pos = v0.screenpos;
|
||||
Vec4<int> prim_color = Vec4<int>::FromRGBA(v0.color0);
|
||||
Vec3<int> sec_color = Vec3<int>::FromRGB(v0.color1);
|
||||
|
||||
auto &pixelID = state.pixelID;
|
||||
auto &samplerID = state.samplerID;
|
||||
@@ -1446,8 +1445,10 @@ void DrawPoint(const VertexData &v0, const BinCoords &range, const RasterizerSta
|
||||
prim_color = ApplyTexturingSingle(s, t, ToVec4IntArg(prim_color), texLevel, texLevelFrac, bilinear, state);
|
||||
}
|
||||
|
||||
if (!pixelID.clearMode)
|
||||
if (!pixelID.clearMode) {
|
||||
Vec3<int> sec_color = Vec3<int>::FromRGB(v0.color1);
|
||||
prim_color += Vec4<int>(sec_color, 0);
|
||||
}
|
||||
|
||||
u8 fog = 255;
|
||||
if (pixelID.applyFog) {
|
||||
|
||||
Reference in New Issue
Block a user